This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes PrintWriter Problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "PrintWriter Problem?" Watch "PrintWriter Problem?" New topic

PrintWriter Problem?

Gregory Thomas

Joined: Jun 01, 2004
Posts: 11
I am using PrintWriter to output the results of my query that has 6,000 records. It properly inserts them into the database but not outputting to a text file. It stops printing the results at about 5000 out of the 6000 rows (records).

StringBuffer insertBfr = new StringBuffer();
insertBfr.append("INSERT INTO x_table VALUES (").append( so forth....


Is there a limit on how much data I could output using the PrintWriter class?

Thanks in advance.
Henrique Sousa
Ranch Hand

Joined: Apr 29, 2004
Posts: 92
Hi Gregory,
It seems to me that you are printing the whole file in a single println(...) statement, is that right? If this is the case, I suggest you split it so that you print each sql insert statement at a time (you probably have a for loop, so it is not a big change). Two advantages on that approach: memory saving -- no huge StringBuffer walking around -- and it would be easier to find out why the file isn't fully written.
That might solve the problem also, but it is just an assumption.

Henrique Sousa<br />SCJP 1.4<br /> <br />All men die, not all men really live - Braveheart, 1995
Gregory Thomas

Joined: Jun 01, 2004
Posts: 11
Henrique...Thank you for your fast reply. Yes, it is in a loop. I will try your suggestion and will post the results after my run. Thank you again.
subject: PrintWriter Problem?
It's not a secret anymore!