try { BufferedWriter out = new BufferedWriter(new FileWriter("outfilename")); out.write("We are writing a line of text to our text file\nThis is our second line of text"); out.close(); } catch (IOException e) { }