Tengo una pequeña duda y es que no se como hacer para que cuando añadas información en un fichero txt pues salga una debajo de la otra , Si alguien sabe como hacerlo estaría muy guay, Estuve buscando por mi cuenta pero no me sale , lo he intentado varias veces pero tampoco me sale. El resultado de que me sale es:Josep;20;SantsMaria;20;Sants , es decir todo junto
public void anadirClientes(){
Scanner input=new Scanner(System.in);
BufferedWriter bw = null;
FileWriter fw = null;
try {
String name;
String edad;
String barrio;
System.out.println("Introduce nombre");
name=input.nextLine();
System.out.println("Introduce edad");
edad=input.nextLine();
System.out.println("Introduce barrio");
barrio=input.nextLine();
File file = new File("clientes.txt");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
fw = new FileWriter(file.getAbsoluteFile(), true);
bw = new BufferedWriter(fw);
bw.write(name);
bw.write(";");
bw.write(edad);
bw.write(";");
bw.write(barrio);
bw.write("\n");
System.out.println("información agregada!");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bw != null)
bw.close();
if (fw != null)
fw.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
\n