Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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

    public class XmlStreamWriter

extends Writer

Character stream that handles all the necessary Voodo to figure out the charset encoding of the XML document written to the stream.

Since:
  Commons IO 2.0
Version:
  $Id: XmlStreamWriter.java 1004737 2010-10-05 17:56:04Z niallp $
Author:
  Herve Boutemy
See Also:
  `XmlStreamReader`

Field Summary

Fields inherited from class java.io.Writer
`lock`

Constructor Summary
`XmlStreamWriter(File file)` Construct an new XML stream writer for the specified file with a default encoding of UTF-8.
`XmlStreamWriter(File file, String defaultEncoding)` Construct an new XML stream writer for the specified file with the specified default encoding.
`XmlStreamWriter(OutputStream out)` Construct an new XML stream writer for the specified output stream with a default encoding of UTF-8.
`XmlStreamWriter(OutputStream out, String defaultEncoding)` Construct an new XML stream writer for the specified output stream with the specified default encoding.

Method Summary
`void` | `close()` Close the underlying writer.
`void` | `flush()` Flush the underlying writer.
`String` | `getDefaultEncoding()` Return the default encoding.
`String` | `getEncoding()` Return the detected encoding.
`void` | `write(char[] cbuf, int off, int len)` Write the characters to the underlying writer, detecing encoding.

Methods inherited from class java.io.Writer
`append, append, append, write, write, write, write`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XmlStreamWriter

    public XmlStreamWriter(OutputStream out)

  Construct an new XML stream writer for the specified output stream with a default encoding of UTF-8.

  Parameters:
    `out` - The output stream

### XmlStreamWriter

    public XmlStreamWriter(OutputStream out,
                           String defaultEncoding)

  Construct an 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

### XmlStreamWriter

    public XmlStreamWriter(File file)
                    throws FileNotFoundException

  Construct an 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

### XmlStreamWriter

    public XmlStreamWriter(File file,
                           String defaultEncoding)
                    throws FileNotFoundException

  Construct an 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

Method Detail

### getEncoding

    public String getEncoding()

  Return the detected encoding.

  Returns:
    the detected encoding

### getDefaultEncoding

    public String getDefaultEncoding()

  Return the default encoding.

  Returns:
    the default encoding

### close

    public void close()
               throws IOException

  Close the underlying writer.

  Specified by:
    `close` in interface `Closeable`
  Specified by:
    `close` in class `Writer`
  Throws:
    `IOException` - if an error occurs closing the underlying writer

### flush

    public void flush()
               throws IOException

  Flush the underlying writer.

  Specified by:
    `flush` in interface `Flushable`
  Specified by:
    `flush` in class `Writer`
  Throws:
    `IOException` - if an error occurs flushing the underlying writer

### write

    public void write(char[] cbuf,
                      int off,
                      int len)
               throws IOException

  Write the characters to the underlying writer, detecing encoding.

  Specified by:
    `write` in 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2010 The Apache Software Foundation. All Rights Reserved.