Re: How to put Enter key character (!_NEWLINE_!) in text file (Urgent)
Posted By:
hacene_khellaf
Posted On:
Monday, September 10, 2001 03:21 AM
hi Ali,
you have to solutions for your question, either you use a primitive
FileOutputStream, and the to each line you add at the end the "
" character like in the following :
FileOutputStream fos = new
FileOutputStream("your file name ");
fos.write(("your text"+"
").getBytes());
you do this for each line.
or just to wrap your FileOutputStream in a writer like PrintWriter since you are storing only text, or a PrintStream.
the 2 last classes have the println method which do the job for you
and you don't have to worry about "
" character :
examples :
PrintWriter pw = new PrintWriter(new FileOutputStream("your file"));
pw.println("your text");
pw.flush();
hope it helps
Hacene