I am working on a proxy server. I am getting data in byte[]
which I convert into a String
to perform certain operations. Now when i convert this new String
back into a byte[]
it causes unknown problems.
So mainly its like I need to know how to correctly convert abyte[]
into a String
and then back into a byte[]
again.
I tried to just convert the byte[]
to String
and then back to byte[]
again (to make sure thats its not my operations that are causing problems).
So it's like:
// where reply is a byte[]
String str= new String(reply,0, bytesRead);
streamToClient.write(str.getBytes(), 0, bytesRead);
is not equivalent to
streamToClient.write(reply, 0, bytesRead);
my proxy works fine when I just send the byte[]
without any conversion but when I convert it from byte[]
to a String
and then back to a byte[]
its causes problems.
Can some one please help? =]