How should I handle searching through byte arrays in Java?

Posted by Zombies on Stack Overflow See other posts from Stack Overflow or by Zombies
Published on 2010-05-02T01:16:59Z Indexed on 2010/05/02 1:27 UTC
Read the original article Hit count: 255

Filed under:
|
|
|

Preliminary: I am writting my own httpclient in Java. I am trying to parse out the contents of chunked encoding.

Here is my dilema: Since I am trying to parse out chunked http transfer encoding with a gzip payload there is a mix of ascii and binary. I can't just take the http resp content and convert it to a string and make use of StringUtils since the binary data can easily contain nil characters. So what I need to do is some basic things for parsing out each chunk and its chunk length (as per chunked transfer/HTTP/1.1 spec).

Are there any helpful ways of searching through byte arrays of binary/part ascii data for certain patterns (like a CR LF) (instead of just a single byte) ? Or must I write the for loops for this?

© Stack Overflow or respective owner

Related posts about java

Related posts about bytearray