aspose file tools*
The moose likes Beginning Java and the fly likes enter to new line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "enter to new line" Watch "enter to new line" New topic
Author

enter to new line

ravi krishna muthireddy
Greenhorn

Joined: Apr 02, 2007
Posts: 9
hello sir
iam retriving fields from table and adding it to
vector while writing it to file every field should entered
into new line, as i am using FileWriter for writing

String empno=rs.getInt(1);
Vector v=new Vector();
v.add(empno);
FileWriter f=new FileWriter(filename);
value retrived from vector say x
f.write(x);
f.flush();

sir here it is appending everything into single line
like
empno;ename;desg;sal;
but i want everthing in new line
empno;
ename;
desg;
sal;
like this
Suleman zia
Ranch Hand

Joined: Apr 19, 2007
Posts: 70
You can use Stringbuffer. check the api docs.


SCJP 1.5
rohit leeta
Ranch Hand

Joined: May 02, 2007
Posts: 49
As far as i understand your problem, you should read this class/method:
http://java.sun.com/j2se/1.4.2/docs/api/java/io/BufferedWriter.html#newLine()


<a href="http://www.java-forums.org" target="_blank" rel="nofollow">Java Forums</a>
Sidd Kulk
Ranch Hand

Joined: Feb 20, 2007
Posts: 152
Also your code would be much more readable if you could use code tags.



And for your doubt, you can use escape characters like \n or \t to provide spaces or new line breaks. StringBuffer could be used as well.

Sid
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: enter to new line