i am having a program in java.which system.out some strings,i need to save each of them in a text file
it is showing in a format
ruo1 row2 row3
i want it in
Very quick code. I apologize if there are compile errors.
import java.io.FileWriter;
import java.io.IOException;
public class TestClass {
public static String newLine = System.getProperty("line.separator");
public static void main(String[] a) {
FileWriter writer;
try {
writer = new FileWriter("test.txt");
for(int i=0;i<3;i++){
writer.write(row+i+newLine);
}
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
u can use PrintWriter pw;
pw.println(row+i)
in above instead of hard coding newLine
how about adding a new line character "\n" to each row ?