+ 1

De que forma inserir uma quebra de linha no arquivo ?

Codigo: try { File x = new File("C:\\testeJava\\test3.txt"); Scanner sc = new Scanner(x); while(sc.hasNext()) { System.out.print(" "+sc.next()); } sc.close(); } catch (FileNotFoundException e) { System.out.println("Error"); } Saída: 1 John Smith 2 Amy Brown

6th Jan 2020, 10:37 AM
Alex Jose Silva
Alex Jose Silva - avatar
5 odpowiedzi
+ 3
while(sc.hasNext()) { System.out.print(sc.next()+" "); if(sc.hasNextInt()) System.out.println(); } sc.close(); }
6th Jan 2020, 12:14 PM
Avinesh
Avinesh - avatar
+ 2
¿Cómo quieres que se vea tu salida?
6th Jan 2020, 11:35 AM
Avinesh
Avinesh - avatar
+ 2
¿Cómo se almacena en el archivo?
6th Jan 2020, 11:39 AM
Avinesh
Avinesh - avatar
0
1 John Smith 2 Amy Brown
6th Jan 2020, 11:35 AM
Alex Jose Silva
Alex Jose Silva - avatar
0
1 John Smith 2 Amy Brown
6th Jan 2020, 11:43 AM
Alex Jose Silva
Alex Jose Silva - avatar