I am learning how to save to a text file, and i am having some trouble creating a new line. I'm sure it is a quick and easy fix, but I can't find my problem. Here is my code.
When i run this, i get :Code:package testsave;
import java.io.*;
public class TestSave {
public static void main(String[] args) {
String text = "Hello World!";
String text1 = "Hello to you too!";
try{
FileWriter file = new FileWriter(text +".txt");
file.write(text + " \n");
file.write(text1 +" \n");
}catch(IOException ex){
ex.printStackTrace();
}
}
}
Hello World! Hello to you too!
Thanks for the help!
