From: Pim Blokland (email@example.com)
Date: Wed Mar 12 2003 - 13:34:13 EST
Jain, Pankaj (MED, TCS) schreef:
> while((chunk = ipStream.read())!=-1)
> byte byChunk = new Integer(chunk).byteValue();
> strBuf.append((char) byChunk);
You don't say which type your "chunk" variable is, but the problem
is definitely in the number of conversions you do.
In this tiny piece of code you convert the input from (whatever
"chunk" is) into Integer, then to byte and finally to char.
As I understand it, char is a signed 16 bits type in Java; any of
the others may be unsigned. Hence the problem. You can try stripping
off the high bits after conversion to char (i.e. (byChunk&127) at
the end) or try to circumvent all those conversions altogether.
This archive was generated by hypermail 2.1.5 : Wed Mar 12 2003 - 14:22:40 EST