iteration - Iterating over a Bytebuffer of chars in java -


im having issue finding solution problem. have bytebuffer of chars(lines of text exact) , need find sub-string in buffer. easiest solution convert bytebuffer string , work string solution requires me double(at least) amount of memory use in stack(or heap) of program , dont want that, rather along lines of each line convert string , work that. there , easy way doing that? thanks.

you read bytebuffer bytes in buffer until finding breakline character or character doesn't make part of string find.
use method :

java.nio.bytebuffer.get(byte[] dst, int offset, int length) 

then convert bytes string (new string(bytes, yourencoding)) , check if contains string match.
otherwise read following bytes , repeat same processing.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -