Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

buffer whole file  RSS feed

 
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 ...
 
Sheriff
Posts: 21187
87
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?
 
author
Sheriff
Posts: 23309
125
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
Boost this thread!