Package org.apache.johnzon.core.io
Class BoundedOutputStreamWriter
- java.lang.Object
-
- java.io.Writer
-
- org.apache.johnzon.core.io.BoundedOutputStreamWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
public class BoundedOutputStreamWriter extends Writer
OutputStreamWriter
delegating directly to a sun.nio.cs.StreamEncoder with a controlled underlying buffer size. It enables to wrap anOutputStream
as aWriter
but with a faster feedback than a defaultOutputStreamWriter
which uses a 8k buffer by default (encapsulated).Note: the "flush error" can be of 2 characters (lcb in StreamEncoder) but we can't do much better when encoding.
-
-
Constructor Summary
Constructors Constructor Description BoundedOutputStreamWriter(OutputStream outputStream, Charset charset, int maxSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Writer
append(char c)
Writer
append(CharSequence csq)
Writer
append(CharSequence csq, int start, int end)
void
close()
void
flush()
void
write(char[] cbuf)
void
write(char[] chars, 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
nullWriter
-
-
-
-
Field Detail
-
delegate
private final Writer delegate
-
-
Constructor Detail
-
BoundedOutputStreamWriter
public BoundedOutputStreamWriter(OutputStream outputStream, Charset charset, int maxSize)
-
-
Method Detail
-
write
public void write(int c) throws IOException
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
public void write(char[] chars, int off, int len) throws IOException
- Specified by:
write
in classWriter
- Throws:
IOException
-
write
public void write(String str, int off, int len) throws IOException
- Overrides:
write
in classWriter
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
write
public void write(char[] cbuf) throws IOException
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
public void write(String str) throws IOException
- Overrides:
write
in classWriter
- Throws:
IOException
-
append
public Writer append(CharSequence csq) throws IOException
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
append
public Writer append(CharSequence csq, int start, int end) throws IOException
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
append
public Writer append(char c) throws IOException
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
-