<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi everyone,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>recently I have developed a project with JDOM.
Everything is fine until I got the request from the greek partner
to support the Greek character in the Java application. After several
testing and discussion with some people in Greek, we find out that I need use
UTF-16 encoding system. The java application works fine with UTF-16 encoding.
But I got the problem with the JDOM parse.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I used the Java application to capute the Greek
characters in the user interface, and use XMLOutputter to write the xmlfile with
the encoding UTF-16. However, when I use JDOM parse to read the file back, I got
the problem.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Here is my code to read the xml back:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> // code start here, fname is the
name of the xml file which is created by the XMLOutputer</FONT></DIV>
<DIV><FONT face=Arial
size=2> SAXBuilder
builder = new
SAXBuilder();<BR>
FileInputStream fis = new
FileInputStream(fname);<BR>
InputStreamReader isr = new InputStreamReader(fis,
"UTF-16");<BR>
Document anotherDocument =
builder.build(isr);<BR>
return anotherDocument;</FONT></DIV>
<DIV><FONT face=Arial size=2> // code end</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>When try to run it, I got the following error
message:</FONT></DIV>
<DIV><FONT face=Arial size=2>// error message here</FONT></DIV>
<DIV><FONT face=Arial size=2> org.jdom.JDOMException: Error on
line 1: Character conversion error: "Missing byte-order mark" (line
number may be too
low).<BR> at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:300)<BR>
at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:650)<BR>
at
qdtJDom.readDocument(qdtJDom.java:134)<BR>
at qMetaJDom.<init>(qMetaJDom.java:33)</FONT></DIV>
<DIV><FONT face=Arial size=2>// error message end</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Anyone has any idea how to solve this problem? By
the way, when I changed the encoding system to UTF-8, the XMLoutputter and
SAXBuilder can works without any error message, but all Greek characters will be
replaced by the ??????.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>thanks in advance for any kind of
tips,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Defeng</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>University of Edinburgh</FONT></DIV>
<DIV> </DIV></BODY></HTML>