Details
-
Type: Bug
-
Status: Closed
-
Resolution: Incomplete
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
JDK version and platform:Java 1.6 for Win32
Description
Hi,
I've run in a problem with streams. Here a quick & dirty example:
try
{ XStream xs = new XStream(); int size = 250; byte[] buf = new byte[size]; for (int i = 0; i < size; i++) buf[i] = (byte) (i + 1); String original = new String(buf, "ISO-8859-1"); ByteArrayOutputStream os = new ByteArrayOutputStream(); xs.toXML(original, os); byte[] st = os.toByteArray(); InputStream is = new ByteArrayInputStream(st); String copy = (String) xs.fromXML(is); System.out.println(original.equals(copy)); // -> false !!!!! System.exit(0); }catch (Exception e)
{ e.printStackTrace(); }The line "System.out.println(original.equals(copy)); " prints out "false". I would expect "true".
Hi Dieter,
as Guilherme and David already answered on the list, it depend on the way you're initializing your streams. Use an OutputStreamWriter with the proper encoding. Please use the list as first time information.