java - how BufferedInputStream.available works? -
fileinputstream in=new fileinputstream("dd.txt"); bufferedinputstream bufi= new bufferedinputstream(in); system.out.println(bufi.available()); int half =bufi.available()/2; bufi.skip(half); system.out.println(bufi.available());
output:
7
4
in "dd.txt" there 1234567
but why bufi can skip before use bufi.read(),i mean when data sent input stream?
it works adding number of bytes buffered, possibly zero, value returned available()
method of wrapped stream. in case wrapped stream fileinputstream
, available()
method returns, arguably incorrectly, number of bytes remaining read in file.
there no reason why skip()
should not possible prior read()
. data never 'sent t imoitbstream'. read by input stream.
Comments
Post a Comment