Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most efficient way to write a string to a file [duplicate]

Possible Duplicate:
How do I save a String to a text file using Java?

I want to add a reading from a machine to a file (Java). The reading will be in the form of a string that I have formatted. The file is just a text file. At the moment I am considering Filewriter/Buffered writer is this the correct one to use?

like image 874
DavyGravy Avatar asked Oct 30 '12 08:10

DavyGravy


1 Answers

Use FileWriter will do you job.

BufferedWriter writer = new BufferedWriter( new FileWriter( yourfilename));
writer.write( yourstring);
// do stuff 
writer.close();
like image 137
Sumit Singh Avatar answered Oct 05 '22 11:10

Sumit Singh