Output br.markSupported():true Contents of file abcddefContents of file java.io.IOException: Mark invalid at java.io.BufferedReader.reset(Unknown Source) at BufferedTest.main(BufferedTest.java:42)
When i invoked mark() i was expecting that file has now been marked @ position 1. And any call to reset() later will re-position the marker which is now at the eof because the contents have been read via readLine() to the postion 1. But this did not happpen and i get Mark invalid exception. Please help. Deepak Preparing for SCJP
I believe you've misunderstood the parameter for the mark() method. It's not the offset at which the mark should be created, but the number of bytes that can be subsequently read while still preserving the mark. It always marks the current read position.
After using br.mark(100); it worked. Even after repeadtedly reading mark() am not understanding the concept. Let me switch of Enrique and try and understand again. Will appreciate if someone can explain this. Thanks Deepak
The reset() call need not fail after exceeding the specified number of bytes. All that the API says is that it may fail. In other words, you're guaranteed that it won't fail before exceeding that many bytes, but it can fail at any point afterward. The exact point at which it'll begin to fail is dependent on the exact implementation (typically depending on the internal buffer size).
I am running into the same issue. I have below function. I get this error: "java.io.IOException: Mark invalid". on bufferedReader.reset();
The strange thing is same code works on one server but fails on another one.
Can some one please tell what may be the issue?