This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Write multiple lines to file

 
Luis Fernandes
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a query that returns all the clientes in my store

I have the following code :


this code create the file well, but only write the first client ( On line )

Can someone tell me what�s the problem ?

i know that in database i have 60 clients, because my System.out.println(resultSet.getString(1)); print the 60 clients

Obrigado desde ja !
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to put the opening and closing of the writer outside the loop. This way, for every iteration, you reopen the file, overwrite its contents, then close it again.


I also included a try-finally block to make sure that the writer gets closed, even if something goes wrong.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!