• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is there a limit for BufferedWriters?  RSS feed

 
Ana Rita Correia Teixeira
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a BufferedWrite to log a process that runs several times and most of the time it works ok, except that sometimes I get an IOException - Stream closed and I can't make any sense of it. I open the BW at the beggining of the iteration and close it at the end, and I'm sure there's no other place where it gets closed. I create a differente BW for each iteration and I have it write in a different file. I also flush it several times during the process, so I can follow it accurately.

At first I thought that if the file gets to big it just can't write anymore, but I have BWs closing at 4Mb and other at 400K. Then I thought it could be not the size but the extention, because they always closed at 20000 or so lines, but now I've seen that some files only have 3000 lines.

I've looked around and I can't find any solution. Most of the problems related with BWs are because of not closing, or closing too soon or in the wrong place. I've debugged it line by line and I'm sure I don't close it anywhere else but at the end. Does anyone have any ideas?
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only limits on writing data are those imposed by the physical media and the file system.
Can you give us a small example of code that exhibits this behaviour?
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never have a Stream to a local file close on it's own. If you are opening a BufferredWriter to a local file, and it's closing prematurely, the problem is most probably that you have a bug that closes the underlying stream earlier than you expect.
 
Ana Rita Correia Teixeira
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for youy answers. I've finally managed to find out what it was: user privileges. I still don't understand why the exception doesn't report that error, but I've asked to have my privileges changed and now it works correctly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!