java - mark and readAheadLimit -
i have case need peek ahead in stream existence of regular look , read info stream.
mark , reset allow me facing issue mark becomes invalid if readaheadlimit goes beyond size of current buffer.
for example: have bufferedreader buffer size of 1k.
lets @ position 1000 (mark=1000) in buffer , need check regex in next 100 chars (readaheadlimit=100).
so while reading, moment i cross current buffer size (1024), new buffer allocated , mark becomes invalid (not able reset) , info streamed new buffer in normal way.
i think intended behavior there way around this?
appreciate help.
regards
the moment cross current buffer size (1024), new buffer allocated
no isn't. existing buffer cleared , readied use.
and mark becomes invalid (not able reset)
no doesn't, unless you've gone beyond read ahead limit.
you don't seem have read api. phone call mark() argument says how far ahead want go before calling reset(), in case 100 bytes, , api required allow that. when 100 characters ahead, phone call reset(), , when called mark(). how happens internally isn't problem, required happen.
and how did bufferedreader 1k buffer? default 4096.
java inputstream iostream bufferedreader java-io
No comments:
Post a Comment