import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
public class extractvalues {
@SuppressWarnings("null")
public static void main(String [] args)
{
try{
// command line parameter
FileInputStream fstream = new FileInputStream("c:/kdd.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
//to Read values
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null)
{
System.out.println(strLine);
String[] splitted=null;
//split the given line into array of words seperated by comma
splitted=strLine.split(",");
int i=0;
//continue loop till it find "." since everyline contain "." in the end
while(!".".equals(splitted))
{
//print each string one by one
System.out.println(splitted[i++]);
}
}
//Close the input stream
in.close();
}
catch (Exception e)
{//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}
Я бегу 2 в то время как петля. Первый цикл будет читать строки за строкой из файла .txt, а второй while цикл будет читать каждую строку из строки. Но когда я запускаю цикл, он читает первую строку и строку, а затем останавливается. Я не понимаю, где я ошибаюсь. Мне не хватает чего-то, пожалуйста, помогите !., а внешний цикл работает один раз?
Его работа прекрасна, спасибо. что было не так в моем коде? –
Отметьте, что потребуется еще 3 минуты, прежде чем я смогу отметить. –