This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

enter to new line

 
ravi krishna muthireddy
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Stringbuffer. check the api docs.
 
rohit leeta
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()
 
Sidd Kulk
Ranch Hand
Posts: 152
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic