I need to write a byte stream onto the network, what i plan to do is take the byte arrays i have, convert them to a string and recreate the byte array using the string i receive on the other end.

Let me illustrate my problem...

1. bss is what i wish to transfer
byte bss[] = new byte[1];
bss[0] = (byte) (129 & 0xff);
System.out.println("Byte value: " + bss[0]);
System.out.println("Int value: " + ( bss[0] & 0xff ));

2. convert bss to a string
StringBuffer ston = new StringBuffer();
ston.append(new String(bss,"UTF-8"));

3. Recreate bss from string
byte bss2[] = ston.toString().getBytes();
System.out.println("Byte value: " + bss2[0]);
System.out.println("Int value: " + ( bss2[0] & 0xff ));

For some reason my output is:-
Byte value: -127
Int value: 129
Byte value: 63
Int value: 63

I need the same byte value and int value after recreating the bytes using getBytes(), i think there is some issue with the encoding issues coming up, wondering if anyone knows a fix for what i'm trying to do..