Package org.apache.commons.io.output
Class XmlStreamWriter
java.lang.Object
java.io.Writer
org.apache.commons.io.output.XmlStreamWriter
- All Implemented Interfaces:
- Closeable,- Flushable,- Appendable,- AutoCloseable
Character stream that handles all the necessary work to figure out the charset encoding of the XML document written to the stream.
 
 To build an instance, use XmlStreamWriter.Builder.
 
- Since:
- 2.0
- See Also:
- 
Nested Class SummaryNested Classes
- 
Field Summary
- 
Constructor SummaryConstructorsConstructorDescriptionXmlStreamWriter(File file) Deprecated.XmlStreamWriter(File file, String defaultEncoding) Deprecated.Deprecated.XmlStreamWriter(OutputStream out, String defaultEncoding) Deprecated.
- 
Method SummaryModifier and TypeMethodDescriptionstatic XmlStreamWriter.Builderbuilder()Constructs a newXmlStreamWriter.Builder.voidclose()Closes the underlying writer.voidflush()Flushes the underlying writer.Returns the default encoding.Returns the detected encoding.voidwrite(char[] cbuf, int off, int len) Writes the characters to the underlying writer, detecting encoding.
- 
Constructor Details- 
XmlStreamWriterDeprecated.Constructs a new XML stream writer for the specified file with a default encoding of UTF-8.- Parameters:
- file- The file to write to
- Throws:
- FileNotFoundException- if there is an error creating or opening the file
 
- 
XmlStreamWriterDeprecated.Constructs a new XML stream writer for the specified file with the specified default encoding.- Parameters:
- file- The file to write to
- defaultEncoding- The default encoding if not encoding could be detected
- Throws:
- FileNotFoundException- if there is an error creating or opening the file
 
- 
XmlStreamWriterDeprecated.Constructs a new XML stream writer for the specified output stream with a default encoding of UTF-8.- Parameters:
- out- The output stream
 
- 
XmlStreamWriterDeprecated.Constructs a new XML stream writer for the specified output stream with the specified default encoding.- Parameters:
- out- The output stream
- defaultEncoding- The default encoding if not encoding could be detected
 
 
- 
- 
Method Details- 
builderConstructs a newXmlStreamWriter.Builder.- Returns:
- a new XmlStreamWriter.Builder.
- Since:
- 2.12.0
 
- 
closeCloses the underlying writer.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein class- Writer
- Throws:
- IOException- if an error occurs closing the underlying writer
 
- 
flushFlushes the underlying writer.- Specified by:
- flushin interface- Flushable
- Specified by:
- flushin class- Writer
- Throws:
- IOException- if an error occurs flushing the underlying writer
 
- 
getDefaultEncodingReturns the default encoding.- Returns:
- the default encoding
 
- 
getEncodingReturns the detected encoding.- Returns:
- the detected encoding
 
- 
writeWrites the characters to the underlying writer, detecting encoding.- Specified by:
- writein class- Writer
- Parameters:
- cbuf- the buffer to write the characters from
- off- The start offset
- len- The number of characters to write
- Throws:
- IOException- if an error occurs detecting the encoding
 
 
- 
builder(),XmlStreamWriter.Builder, andXmlStreamWriter.Builder.get()