• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
That feels good. Thanks. Here's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic