Tuesday, 15 February 2011

java - Exception at the BufferedReader.reset() method -



java - Exception at the BufferedReader.reset() method -

i have hasnext() method reading file. returns true if it's not end of file. in method has exception.

exception information:

exception at: java.io.bufferedreader.reset(bufferedreader.java:497) typ: java.io.ioexception message: mark invalid

my hasnext() method:

@override public boolean hasnext() { seek { super.getsourceread().mark(1); if (super.getsourceread().read() < 0) { homecoming false; } getsourceread().reset(); homecoming true; } grab (ioexception e) { logger.exceptionoccurred(e); homecoming false; } grab (nullpointerexception e) { logger.exceptionoccurred(e); homecoming false; } }

well it's written in doc 1.5:

after reading this many characters, attempting reset stream may fail.

so in case says may fail after reading 1 character.

setting limit 2 puts in safe zone.

and create nagging style remark: hope have constant or fellow member limit somewhere in class (sorry had :) )

java file-io bufferedreader ioexception mark

No comments:

Post a Comment