• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the best approach to write result set data to flat file?

 
Siva Vu
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best approach to write result set data to flat file?

Thanks
 
Dominique Ramoney
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try
 
Siva Vu
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What to try?
 
Siva Vu
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The new new line is not being created if I use escape charecter '\n' when using FileWriter.
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Common problem. The end-of-line marker varies from platform to platform and simple-minded programs like Windows Notepad can't tell the difference. Windows uses "/n/r", Unix '/n' and Mac '/r'. Since Java is designed to be cross platform one can obtain proper marker in a couple of different ways:
System.getProperties("line.separator") will return it as a String. java.io.PrintWriter.println() will append the proper separator with each call.
java.io.BufferedWriter.newLine() will write a line separator directly to the file.
Use whatever method fits best with your requirements.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course Joe's slashing / / / when he should be slishing \ \ \. A hopeless case of Windophobia, IMO...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!