org.mmbase.util
Class EncodingDetectingOutputStreamWriter

java.lang.Object
  extended by java.io.Writer
      extended by org.mmbase.util.EncodingDetectingOutputStreamWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class EncodingDetectingOutputStreamWriter
extends Writer

Like OutputStreamWriter but it tries to autodetect the encoding of the OutputStream. This works at least if the OutputStream is XML, which is a very common thing to be for Resources. For this to work at least the first part (e.g. the first 100 bytes) need to be buffered. If determining the encoding did not succeed it is supposed to be 'UTF-8', which is (should be) an acceptable encoding, and also the default encoding for XML streams.

Since:
MMBase-1.8
Version:
$Id: EncodingDetectingOutputStreamWriter.java 41036 2010-02-15 22:30:54Z michiel $
Author:
Michiel Meeuwissen

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
EncodingDetectingOutputStreamWriter(OutputStream os)
           
 
Method Summary
 void close()
           
 void flush()
           
 void write(char[] cbuf)
           
 void write(char[] cbuf, int off, int len)
           
 void write(int c)
           
 void write(String str)
           
 void write(String str, int off, int len)
           
 
Methods inherited from class java.io.Writer
append, append, append
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncodingDetectingOutputStreamWriter

EncodingDetectingOutputStreamWriter(OutputStream os)
Method Detail

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Writer
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Specified by:
flush in class Writer
Throws:
IOException

write

public void write(char[] cbuf)
           throws IOException
Overrides:
write in class Writer
Throws:
IOException

write

public void write(int c)
           throws IOException
Overrides:
write in class Writer
Throws:
IOException

write

public void write(String str)
           throws IOException
Overrides:
write in class Writer
Throws:
IOException

write

public void write(String str,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class Writer
Throws:
IOException

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
Specified by:
write in class Writer
Throws:
IOException


MMBase 2.0-SNAPSHOT - null