org.mmbase.util
Class WriterOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.mmbase.util.WriterOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class WriterOutputStream
extends OutputStream

Oddly enough, Java does not provide this itself. It is necessary though in GenericResponseWrapper, because you sometimes are stuck with a writer, while an outputStream is requested. Code inspired by http://www.koders.com/java/fid5A2897DDE860FCC1D9D9E0EA5A2834CC62A87E85.aspx

Since:
MMBase-1.7.4
Author:
Michiel Meeuwissen

Field Summary
protected  String encoding
           
protected  Writer writer
           
 
Constructor Summary
WriterOutputStream(Writer writer, String encoding)
           
 
Method Summary
 void close()
           
 void flush()
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

protected Writer writer

encoding

protected String encoding
Constructor Detail

WriterOutputStream

public WriterOutputStream(Writer writer,
                          String encoding)
Method Detail

close

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

flush

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

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException


MMBase 2.0-SNAPSHOT - null