• Post Reply Bookmark Topic Watch Topic
  • New Topic

Save contents of stringbuffer to new/existing file in ROOT directory

 
Keith Harrison
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I have a problem whereby I want to save the contents of a stringbuffer to a new or existing file in the ROOT directory.

Can anybody offer me any guidance as to how I can achieve this?

Thanks very much.

Keith Harrison
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which part -- opening the file, writing to the file, writing a StringBuffer in particular? What have you got so far?
 
Keith Harrison
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

I have a servlet that obtains a connection to my database and reads various records from a products table. I then loop through the resultset, re-format and add the fields of my choice to a string buffer, similar to CSV format.

I have got this far and have the data ready to send to the file.

I would like to output the data to a text file. (but delete the same filename first if it already exists)
I will then form a URL that points to the file and send it in an email message using my JavaMail class.
I would like to place the file into a folder off my ROOT directory if possible. (For example "/csvs/001.txt")

I would be grateful for any help you can offer.

Thanks,

Keith.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!