org.mmbase.util
Class EncodingDetectingOutputStreamWriter

java.lang.Object
  extended byjava.io.Writer
      extended byorg.mmbase.util.EncodingDetectingOutputStreamWriter

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,v 1.2 2005/01/30 16:46:35 nico Exp $
Author:
Michiel Meeuwissen
To Do:
Is it named correctly?

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
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.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public void close()
           throws IOException
Throws:
IOException

flush

public void flush()
           throws IOException
Throws:
IOException

write

public void write(char[] cbuf)
           throws IOException
Throws:
IOException

write

public void write(int c)
           throws IOException
Throws:
IOException

write

public void write(String str)
           throws IOException
Throws:
IOException

write

public void write(String str,
                  int off,
                  int len)
           throws IOException
Throws:
IOException

write

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


MMBase build 1.8.1.20060716