XML output file with Control M Characters

Hi,

I am using JDOM API 1.0 on Solaris platform.

Using the XMLOuputter I write the XML data to a file. But the XML file contains Control-M characters at the end of each line..like

<User>^M

<Name>Satish</Name>^M

<id>12567</id>^M

</User>^M

File f =new File(path,Constants.USER_XML);

Document doc = getDocument();

XMLOutputter out =new XMLOutputter();

out.setFormat(Format.getPrettyFormat());

Format outFormat = out.getFormat();

outFormat.setLineSeparator(System.getProperty("line.separator"));

outFormat.setIndent(" ");

try{

FileWriter fw =new FileWriter(f);

out.output(doc,fw);

}catch(IOException iox){}

I am not writing the Control-M characters. Also I am using the default encoding which is UTF-8. So how to avoid the control characters. Thanks in advance.

Regards,

Satish

[1260 byte] By [satish_radza] at [2007-9-30 23:34:02]
# 1

Those are carriage-return (CR) characters. I don't know anything about the classes you are using but I would suggest you let the software decide what line endings it is going to use (the XML default is line-feed (LF) only) instead of telling it. Just a guess.

It's also possible that those CRs were in your input document and you are just copying them to the output document. XML parsers are supposed to normalize those characters to only LF but perhaps your parser isn't doing that. Just another guess.

DrClapa at 2007-7-7 14:47:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...