[jdom-interest] What does the encoding really mean?

Fred Clewis clewisf at us.ibm.com
Wed Nov 28 06:36:51 PST 2001


Alex,

When I try to use the XMLOutPutter to output UCS-2 or UCS2 (my guess at the
      java name) I get an unsupported encoding error.
Am I doing something wrong in the code below?  I have to use beta 7 in my
      situation.  thanks,

SAXBuilder builder = new SAXBuilder();
// can't use setfeature with JDOM b7
//builder.setFeature("http://apache.org/xml/features/allow-java-encodings",
true);
builder.setValidation(false);
thisDocument = builder.build(new FileInputStream(xmlFile));
....
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLOutputter xmlOut = new XMLOutputter();
xmlOut.setEncoding("UCS-2"); // also fails UCS2
xmlOut.output(thisDocument, baos);
return baos.toString();

java.io.UnsupportedEncodingException: UCS-2
        at java.lang.Throwable.<init>(Throwable.java:96)
        at java.lang.Exception.<init>(Exception.java:44)
        at java.io.IOException.<init>(IOException.java:49)
        at
java.io.UnsupportedEncodingException.<init>(UnsupportedEncodingExcept
ion.java:39)
        at sun.io.Converters.getConverterClass(Converters.java:97)
        at sun.io.Converters.newConverter(Converters.java:128)
        at
sun.io.CharToByteConverter.getConverter(CharToByteConverter.java:71)
        at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:80)
        at org.jdom.output.XMLOutputter.makeWriter(XMLOutputter.java:451)
        at org.jdom.output.XMLOutputter.makeWriter(XMLOutputter.java:437)
        at org.jdom.output.XMLOutputter.output(XMLOutputter.java:469)




More information about the jdom-interest mailing list