• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

buffer whole file

 
Karsten Daemen
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I want to buffer a reasonable small file completely in a BufferedReader, so i can quickly prints it's output to different output streams. So i wrote this:




this throws:



I have now idea what i'm doing wrong. The file is only 2415 bytes long so the casting to integer can't be a problem I think ...
 
Rob Spoor
Sheriff
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not store the contents in a StringBuilder instead?
 
Henry Wong
author
Marshal
Pie
Posts: 20881
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The exception means that the mark has been invalidated prior to the reset. And from looking at the source, it looks like the mark is invalidated at the instant that you fill up the buffer; you don't even have to read pass it.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic