Package com.twelvemonkeys.io
Class WriterOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- com.twelvemonkeys.io.WriterOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class WriterOutputStream extends java.io.OutputStream
Wraps aWriter
in anOutputStream
.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 underlyingOutputStream
, 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 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
WriterOutputStream.CharsetDecoder
private static interface
WriterOutputStream.Decoder
private static class
WriterOutputStream.StringDecoder
-
Field Summary
Fields Modifier and Type Field Description (package private) java.io.ByteArrayOutputStream
bufferStream
protected WriterOutputStream.Decoder
decoder
private boolean
isFlushing
private static boolean
NIO_AVAILABLE
protected java.io.Writer
writer
-
Constructor Summary
Constructors Constructor Description WriterOutputStream(java.io.Writer pWriter)
WriterOutputStream(java.io.Writer pWriter, java.lang.String pCharset)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
private void
flushBuffer()
private static WriterOutputStream.Decoder
getDecoder(java.lang.String pCharset)
private static boolean
isNIOAvailable()
static void
main(java.lang.String[] pArgs)
void
write(byte[] pBytes)
void
write(byte[] pBytes, int pOffset, int pLength)
void
write(int pByte)
-
-
-
Field Detail
-
writer
protected java.io.Writer writer
-
decoder
protected final WriterOutputStream.Decoder decoder
-
bufferStream
final java.io.ByteArrayOutputStream bufferStream
-
isFlushing
private volatile boolean isFlushing
-
NIO_AVAILABLE
private static final boolean NIO_AVAILABLE
-
-
Method Detail
-
isNIOAvailable
private static boolean isNIOAvailable()
-
getDecoder
private static WriterOutputStream.Decoder getDecoder(java.lang.String pCharset)
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public final void write(byte[] pBytes) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public final void write(byte[] pBytes, int pOffset, int pLength) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public final void write(int pByte)
- Specified by:
write
in classjava.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
-
-