• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

how to write more data to csv file

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OutputStreamWriter outWriter = new OutputStreamWriter(output);
BufferedWriter writer = new BufferedWriter(outWriter, (int) MEG);
private static final double MEG = (Math.pow(1024, 2));

I am using this writer to write database table data to csv file. At a max i was able to write 900000. I need write around 2million of data. Can someone suggest how to improve my buffered writer to do that. Thanks,
 
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have to have a single buffer big enough to hold the entire file, you know. Just choose a reasonable buffer size (say 8192 but don't ask me why not some other number because it really doesn't matter much) and write the data to the buffered writer in the normal way.
 
shashank beerla
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you asking me to increase the private static final double MEG = (Math.pow(1024, 2)); size to 8192?

I didn't get your advise when you mentioned use multiple writers. I am iterating through list of objects and writing to the CSV file. How can i use two writers to accomplish what I am doing
 
Paul Clapham
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shashank beerla wrote:Are you asking me to increase the private static final double MEG = (Math.pow(1024, 2)); size to 8192?



No, because 1048576 is greater than 8192. That wouldn't be an increase.

I didn't get your advise when you mentioned use multiple writers. I am iterating through list of objects and writing to the CSV file. How can i use two writers to accomplish what I am doing



That's because I didn't mention "multiple writers" at all. I don't know where you got that idea from. And if you think I was telling you to use two writers, I don't know where you got that idea from either. On the other hand if that was your idea, then don't do that. Just use one BufferedWriter and write the data to it. Don't forget to close it when you're finished.
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please do take out time to CarefullyChooseOneForum
Your question has nothing to do with GWT. Moving to a more appropriate forum
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic