What String str = new String(bytes) does it to create a java String (i.e. UTF-16) using the default platform character encoding (for windows 2000 this is cp1252).
If the byte array was created from a string encoded in the platform default character encoding this will work well.
If not you need to specify the correct character encoding (Charset) as String str = new String (byte  bytes, Charset charset)
posted 10 years ago
Thanks very much. I only needed a quick way to get data read from FileInputStream.read() quickly out to System.out.println() for debugging purposes. However, knowing about the encoding problem will come in handy for a real application.
Your mind is under my control .... your will is now mine .... read this tiny ad