If I have a byte[] and I convert it to string (String sData = new
String(byte[] bData), then convert it back (byte bData = sData.getBytes( )),
will all data be intact, or do Strings have problems with bytes that are
not printable characters? I've tested this and it seems to work fine, but
I want to make sure there isn't some condition or situation I'm not aware
of that could cause problems.
I'm doing this because it's easier to do some of my work with strings, so
I'm reading a Zip file, saving each entry as a String, modifying some, then
saving it as a new Zip. I've found with Zip files, you can't always be
sure of how much data you'll be able to read in, so I'm reading in data in
blocks upto 2k, then taking each block and converting it to a String, so I
can concatenate the amount read in onto the end of another string. (With
Strings, I can use sString.substri ng(), I can't find a way to concatenate
byte[] arrays without continually creating a new array and using
System.arrayCop y().)
Thanks for any info.
Hal
String(byte[] bData), then convert it back (byte bData = sData.getBytes( )),
will all data be intact, or do Strings have problems with bytes that are
not printable characters? I've tested this and it seems to work fine, but
I want to make sure there isn't some condition or situation I'm not aware
of that could cause problems.
I'm doing this because it's easier to do some of my work with strings, so
I'm reading a Zip file, saving each entry as a String, modifying some, then
saving it as a new Zip. I've found with Zip files, you can't always be
sure of how much data you'll be able to read in, so I'm reading in data in
blocks upto 2k, then taking each block and converting it to a String, so I
can concatenate the amount read in onto the end of another string. (With
Strings, I can use sString.substri ng(), I can't find a way to concatenate
byte[] arrays without continually creating a new array and using
System.arrayCop y().)
Thanks for any info.
Hal
Comment