FABIO MARTINEZ
May 12th, 2000, 09:43 AM
Hi, I'd be very grateful if somebody help.
I need to convert an array of bytes to a String, sending this string as a parameter and getting again a byte array.
The first step is acomplished through new String(byte[] myarray). Then I'm using getbytes() method.
This scheme works ok if bytes containing 0x8d, 0x8e, 0x8f, 0x90, 0x9d, 0x9e, are not involved. If it's not the case in my returned bytearray I obtain 0x3f.
Here is a demonstrating piece of code. Thanks.
javacode/
public static void main(String[] args) {
byte [] byteArray = new byte[256];
for (int i = 0; i < 256; i++) {
byteArray[i] = (byte)i;
}
String kk = new String(byteArray);
byte [] byteArray2 = kk.getBytes();
for (int j = 0; j < 256; j++) {
System.out.println(byteArray[j] + " = " + byteArray2[j]);
}
/javacode
I need to convert an array of bytes to a String, sending this string as a parameter and getting again a byte array.
The first step is acomplished through new String(byte[] myarray). Then I'm using getbytes() method.
This scheme works ok if bytes containing 0x8d, 0x8e, 0x8f, 0x90, 0x9d, 0x9e, are not involved. If it's not the case in my returned bytearray I obtain 0x3f.
Here is a demonstrating piece of code. Thanks.
javacode/
public static void main(String[] args) {
byte [] byteArray = new byte[256];
for (int i = 0; i < 256; i++) {
byteArray[i] = (byte)i;
}
String kk = new String(byteArray);
byte [] byteArray2 = kk.getBytes();
for (int j = 0; j < 256; j++) {
System.out.println(byteArray[j] + " = " + byteArray2[j]);
}
/javacode