Jian Zhang <[EMAIL PROTECTED]> wrote on 06/23/2006 11:50:31 AM:
<snip/>
> // read the content of the file into a string
> static String getDocument(String path) throws
> Exception {
> StringBuffer doc = new StringBuffer();
> //CLOB clob = new CLOB();
> char buf[] = new char[10240];
> int start = 0;
> Reader reader = new InputStreamReader(new
> FileInputStream(path));
This creates an InputStreamReader [1] which uses your platform's default
encoding. If it's not UTF-8 that's probably the problem. You should
specify the encoding explicitly: new InputStreamReader(new
FileInputStream(path), "UTF-8").
> do {
> int len = reader.read(buf, 0, 10240);
> doc.append(new String(buf, 0, len));
> if (len < 10240) {
> break;
> } else {
> start += len;
> }
> } while (true);
> return doc.toString();
> }
>
> ***special_char.xml***
> <?xml version="1.0" encoding="UTF-8"?>
> <Return>
>
> <CapitalGainNetIncome>65774204</CapitalGainNetIncome>
> <DateAcquired>1999-05-30</DateAcquired>
>
> <PropertyDescription>¼</PropertyDescription>
> </Return>
<snip/>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
[1]
http://java.sun.com/j2se/1.5.0/docs/api/java/io/InputStreamReader.html#InputStreamReader(java.io.InputStream)
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]