0

There is a way to read line by line, intead of word by word?

5th May 2016, 6:20 PM
Esdras Antero
Esdras Antero - avatar
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); }
23rd Jun 2016, 10:02 PM
michael edia
michael edia - avatar
+ 1
try (BufferedReader br = new BufferedReader(new FileReader(file))) { String line; while ((line = br.readLine()) != null) { // process the line. } }
19th May 2016, 12:55 PM
James Flanders
0
do what James said, but use hasNextLine in the loop
24th Jun 2016, 2:03 PM
DanI MicraS
DanI MicraS - avatar