I have an arbitrary part that represents bytes, encoded in an arbitrary scheme (ASCII, UTF-8, UTF -16). I know encoding
What I'm trying to do is find the location of the last new line (\ n) in the array of bytes. I want to know how many bytes have been saved after reading the last encoded. \ N.
I can not find anything in JDK or any other library, so that I get a byte array from one to one. InputStreamReader reads the stream in the chunks, giving me no indication that how many bytes are being read to make four characters.
Do I have to do something, encoding every encoding to know each byte length
You can try something like this
charset decoder CD = Charset.FireName ("UTF-8"). NewDecoder (); ByteBuffer = Bitebuffer. In bytes (bytes); Charbufar Outside = Charbuffar.Olock (1); Int p = 0; While (in.hasRemaining ()) {cd.decode (in, out, true); Char c = out.array () [0]; Int nBytes = in.position () - p; P = in.position (); Out.position (0); }
No comments:
Post a Comment