tags:

views:

73

answers:

1

First, I need to read a binary String from file into memory - how ? To read I tried nio.CharBuffer, and then byte[]. But later I need to get a binary String with all possible binary data to do regular expression on, so it was not a success.

Then, I need to extract binary sequences from this binary string and save them in each separate binary file. Regular expr is something like this "some_string \0{4} \2.+?\0{10}", some_string followed by a space, then the \2 byte, then binary data and then 10 NULL bytes.

What would you recommend?

A: 

I'm not sure your using the right tool here, however,

  • make sure you are using a 1-byte encoding such as ISO-8859-1 to convert between String and byte[],
  • note that a '.' in a regexp excludes the end of line character, so you may want to use [\0..\255] instead
Maurice Perry
I'd agree, it sounds like the wrong tool.
Derek Clarkson