How to save a string to a .txt file in java -
this question has answer here:
- how save string text file using java? 18 answers
ive finished application , have tested functions , working. 1 part of inputted data supposed saved .txt file. ive placed inside string im bit out of depth in area , have no idea how save drive on pc. appreciated. code on link: http://sharetext.org/fsy2
try this:
public static void main(string args[])throws ioexception { file file = new file("hello1.txt"); // creates file file.createnewfile(); // creates filewriter object filewriter writer = new filewriter(file); // writes content file writer.write("this\n is\n an\n example\n"); writer.flush(); writer.close(); }
read more abut here
Comments
Post a Comment