Bug 15098 - Enhancement to javadoc for XMLSerializer's Writer-using constructor
Summary: Enhancement to javadoc for XMLSerializer's Writer-using constructor
Status: NEW
Alias: None
Product: Xerces-J
Classification: Unclassified
Component: Serialization (show other bugs)
Version: 1.4.4
Hardware: All All
: P3 enhancement
Target Milestone: ---
Assignee: Xerces-J Developers Mailing List
URL: http://forum.java.sun.com/thread.jsp?...
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-05 03:46 UTC by Jeff Skubick
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Skubick 2002-12-05 03:46:51 UTC
It's not something that users won't figure out eventually, but it would be 
helpful if the Javadoc for XMLSerializer(java.io.Writer writer, OutputFormat 
format) were amended to read:

Constructs a new serializer that writes to the specified writer using the 
specified output format. If format is null, will use a default output format.

WARNING: FileWriter seems convenient, but it probably *won't* reliably do what 
you think it will for this purpose and will likely fail when you least expect 
it. Use an OutputStreamWriter explicitly specifying UTF-8 as a Charset 
instead. 

Example:

// No, no, a billion times NO! --> FileWriter writer = new FileWriter(file);
FileOutputStream outputStream = new FileOutputStream(file);
Charset utf8 = Charset.forName("UTF-8");
OutputStreamWriter writer = new OutputStreamWriter(outputStream, utf8);
XMLSerializer serializer = new XMLSerializer(writer, formatter);