Hi i have aproblem with putputtin data to a txt file i have 3 lines for e.g My name is My age is My nationality is i want all these 3 lines ot be printed in a text file on different lines i used the following FileWriter fw=new Filewriter("news_Archives.txt",true); PrintWriter pw=new PrintWriter(fw,true); But i realised tht the file writer appends to end of the file whereas the print writer flushes o/p to new line.But in this case file writer overrides print writer and my output just gets printed on one line.How do i acheive printing on different lines
Amol Desai
Ranch Hand
Joined: Jan 29, 2003
Posts: 82
posted
0
Hi, You can use the following piece of code String str1="My name is"; String str2="My age is"; String str3="My Nationality is"; try { BufferedWriter bw = new BufferedWriter(new FileWriter("E:/UserDirectory/out.txt"));