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

export daa in CSV and store the file in local drive  RSS feed

 
S Dongan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Here is the requirements.

Fetch the values from table (around 60000 records), and export them into CSV file and store the file in local drive.

I have written servlet to to this and it is working fine expect saving the file in local drive. At the moment, it is asking to save as in local drive. i want to save the file automatically in particular path. Below is the code.

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If when you say 'local' you're talking about writing this to the client's machine, you can't.

Browsers are specifically designed not to allow this behavior.
This is a good thing.
Imagine what would be on your hard drive if any site you stumble into had the ability to do this.
 
S Dongan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. I do not want to save it client's machine directly. I want to save it in the server /var/www/files/ location.
 
S Dongan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the first few lines...


 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the API for the PrintWriter and the FileOutputStream
classes.

 
S Dongan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben.

I tried and it worked like a charm.

Originally posted by Ben Souther:
Have a look at the API for the PrintWriter and the FileOutputStream
classes.

 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget to close the stream.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!