Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

formatting data, and saving same to external file

 
srinivas nama
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to retrieve the data from database, format it, and save the data to external file in csv format... and I am new to java.
 
Ganesh Ram
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To read from a database, you need JDBC. Please read up on how to connect to a database and perform query etc. you can find examples at javasoft.
Formatting would be write each of the relevant columns or any computation performed into a StringBuffer appending commas after every column.
stringbuffer sb = new stringbuffer();
To write to a file, use outputstream.
Fileoutputstream f = Fileoutstream(filename).
bufferedwriter b = new bufferedwriter(new outputstreamwriter(f));
b.writeline(sb.toString());
watch all the cases(lower and upper), i am writing this more as a draft.
 
Richard Rodger
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest way is to use a CSV component that does this. There are many if you search google.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic