prehistory: http://stackoverflow.com/questions/3262013/java-regular-expression-for-binary-string
I can extract a substring with binary data I need, but when I use
String s = matcher.group(1);
It seems that data is spoiled,
to be exact spoiled are only those chars that belong to extended ASCII table, probably from 128 to 255. Other chars are kept untouched, but some are corrupted.
What I basically mean, is that I need to transform this " s " string into byte array, but this:
String s2 = new String(s.getBytes(), "US-ASCII")
or this
String s2 = new String(s.getBytes(), "ISO-8859-1")
and later,
fileOutputStream.write(s2.getBytes())
replaces all chars from extended ASCII table to " ? ", while others like \0 or 'A' are kept uncorrupted.
How to interpret a String as plain [0-255] ascii binary symbols ?
PS I solved it, one should use
String encoding = "ISO-8859-1";
to encode/decode byte arrays, and everything works perfectly.