0
There is a way to read line by line, intead of word by word?
3 Réponses
+ 3
Scanner data = new Scanner(new file("multiple line file.txt"));
while(data.hasNextLine()){
String oneLineOfData = data.nextLine();
System. out.println("This is a line of data from the file: " + oneLineOfData);
}
+ 1
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
String line;
while ((line = br.readLine()) != null) {
// process the line.
}
}
0
do what James said, but use hasNextLine in the loop