Package com.github.marschall.writers
Class BufferedAsciiOutputStreamWriter
- java.lang.Object
-
- java.io.Writer
-
- com.github.marschall.writers.BufferedAsciiOutputStreamWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
public final class BufferedAsciiOutputStreamWriter extends Writer
A writer that encodes to ASCII and buffers.For non-ASCII characters
'?'
will be written instead just likeOutputStreamWriter
does.- Implementation Note:
- This class is not thread-safe., This writer does not allocate any objects, beyond
a
byte[]
for buffering allocated in the constructor, or call methods that allocate objects.
-
-
Constructor Summary
Constructors Constructor Description BufferedAsciiOutputStreamWriter(OutputStream out)
Constructs a newBufferedAsciiOutputStreamWriter
with a default buffer size of 8192.BufferedAsciiOutputStreamWriter(OutputStream out, int bufferSize)
Constructs a newBufferedAsciiOutputStreamWriter
-
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, int offset, int length)
void
write(int c)
void
write(String str, int offset, int length)
-
Methods inherited from class java.io.Writer
nullWriter, write, write
-
-
-
-
Constructor Detail
-
BufferedAsciiOutputStreamWriter
public BufferedAsciiOutputStreamWriter(OutputStream out, int bufferSize)
Constructs a newBufferedAsciiOutputStreamWriter
- Parameters:
out
- the output stream to delegate to, notnull
bufferSize
- the buffer size in bytes, must be positive- Throws:
NullPointerException
- whenout
isnull
IllegalArgumentException
- ifbufferSize
negative or 0
-
BufferedAsciiOutputStreamWriter
public BufferedAsciiOutputStreamWriter(OutputStream out)
Constructs a newBufferedAsciiOutputStreamWriter
with a default buffer size of 8192.- Parameters:
out
- the output stream to delegate to, notnull
- Throws:
NullPointerException
- whenout
isnull
-
-
Method Detail
-
write
public void write(int c) throws IOException
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
public void write(char[] cbuf, int offset, int length) throws IOException
- Specified by:
write
in classWriter
- Throws:
IOException
-
write
public void write(String str, int offset, int length) 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
-
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
-
-