public class OutputStreamOutput extends Object implements Output
Output.Adaptors, Output.Buffer
Constructor and Description |
---|
OutputStreamOutput(OutputStream os) |
Modifier and Type | Method and Description |
---|---|
Output |
append(byte b)
Appends a byte to this
Output . |
Output |
append(byte[] bytes)
Appends a byte array to this
Output . |
Output |
append(byte[] bytes,
int start,
int end)
Appends a subsequence of the specified byte array to this Output.
|
Output |
append(ByteBuffer buffer)
Appends the specified buffer into this Appendable.
|
Output |
append(char c)
Appends the specified character to this Output.
|
Output |
append(CharSequence csq)
Appends the specified character sequence to this Output.
|
Output |
append(CharSequence csq,
int start,
int end)
Appends a subsequence of the specified character sequence to this Output.
|
OutputStream |
asOutputStream()
Create an
OutputStream based on this Output instance. |
Writer |
asWriter()
Create an
Writer based on this Output instance. |
void |
close()
Close this
Output instance. |
void |
flush()
Flushes the output.
|
void |
open()
Prepare this
Output instance for appending. |
public OutputStreamOutput(OutputStream os)
public void open()
Output
Prepare this Output
instance for appending. If any append method is called before calling open()
, then open()
will be called implicitly before appending happens.
public void close()
Output
Close this Output
instance. Call to any append method after the Output
is closed will result in IllegalStateException
public void flush()
Output
Flushes the output. If the output has saved any characters from the various append() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.
If the intended destination of this output is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.
public Output append(CharSequence csq)
Output
Appends the specified character sequence to this Output.
Depending on which class implements the character sequence csq, the entire sequence may not be appended. For instance, if csq is a CharBuffer
then the subsequence to append is defined by the buffer’s position and limit.
append
in interface Appendable
append
in interface Output
csq
- The character sequence to append. If csq is null, then nothing will be appendedpublic Output append(CharSequence csq, int start, int end)
Output
Appends a subsequence of the specified character sequence to this Output.
An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation
out.append(csq.subSequence(start, end))
append
in interface Appendable
append
in interface Output
csq
- The character sequence from which a subsequence will be appended. If csq is null, then nothing will be appended.start
- The index of the first character in the subsequenceend
- The index of the character following the last character in the subsequencepublic Output append(char c)
Output
Appends the specified character to this Output.
append
in interface Appendable
append
in interface Output
c
- The character to appendpublic Output append(byte[] bytes)
Output
Appends a byte array to this Output
.
public Output append(byte[] bytes, int start, int end)
Output
Appends a subsequence of the specified byte array to this Output.
An invocation of this method of the form out.append(bytes, start, end) when bytes is not null, behaves in exactly the same way as the invocation
out.append(csq.subSequence(start, end))
append
in interface Output
bytes
- The byte array from which a subsequence will be appended. If bytes is null, then nothing will be appended.start
- The index of the first character in the subsequenceend
- The index of the character following the last character in the subsequencepublic Output append(byte b)
Output
Appends a byte to this Output
.
public Output append(ByteBuffer buffer)
Output
Appends the specified buffer into this Appendable.
public OutputStream asOutputStream()
Output
Create an OutputStream
based on this Output
instance.
Calling to this method before calling to any other method including asOutputStream()
itself will result in IllegalStateException
.
asOutputStream
in interface Output
OutputStream
reference backed by this Output
.public Writer asWriter()
Output
Create an Writer
based on this Output
instance.
Calling to this method before calling to any other method including asOutputStream()
itself will result in IllegalStateException
.
Copyright © 2014–2018 OSGL (Open Source General Library). All rights reserved.