Class WriterOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class WriterOutputStream
    extends java.io.OutputStream
    Wraps a Writer in an OutputStream.

    Instances of this class are not thread-safe.

    NOTE: This class is probably not the right way of solving your problem, however it might prove useful in JSPs etc. If possible, it's always better to use the Writer's underlying OutputStream, or wrap it's native backing.

    Version:
    $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/io/WriterOutputStream.java#2 $
    • Field Detail

      • writer

        protected java.io.Writer writer
      • bufferStream

        final java.io.ByteArrayOutputStream bufferStream
      • isFlushing

        private volatile boolean isFlushing
      • NIO_AVAILABLE

        private static final boolean NIO_AVAILABLE
    • Constructor Detail

      • WriterOutputStream

        public WriterOutputStream​(java.io.Writer pWriter,
                                  java.lang.String pCharset)
      • WriterOutputStream

        public WriterOutputStream​(java.io.Writer pWriter)
    • Method Detail

      • isNIOAvailable

        private static boolean isNIOAvailable()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public final void write​(byte[] pBytes)
                         throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public final void write​(byte[] pBytes,
                                int pOffset,
                                int pLength)
                         throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public final void write​(int pByte)
        Specified by:
        write in class java.io.OutputStream
      • flushBuffer

        private void flushBuffer()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • main

        public static void main​(java.lang.String[] pArgs)
                         throws java.io.IOException
        Throws:
        java.io.IOException