public class NondisposableOutputStream extends OutputStream
The class that encapsulates a stream that cannot be closed by calling
the OutputStream.close()
method.
Constructor and Description |
---|
NondisposableOutputStream()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Sets the position of the underlying byte array stream to the beginning.
|
void |
flush()
Flushes this output stream and forces any buffered output bytes to be written out.
|
byte[] |
getByteArray()
Returns the stream content as a byte array.
|
void |
write(byte[] b)
Writes
b.length bytes from the specified byte array to this output stream. |
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array starting at offset off to this output stream. |
void |
write(int value)
Writes the specified byte to this output stream.
|
public NondisposableOutputStream()
Creates a new instance.
public void write(int value) throws IOException
Writes the specified byte to this output stream.
The general contract for write
is that one byte is written to the output stream.
The byte to be written is the eight low-order bits of the argument b
.
The 24
high-order bits of b
are ignored.
write
in class OutputStream
value
- The byte to write.IOException
- if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.public void write(byte[] b) throws IOException
Writes b.length
bytes from the specified byte array to this output stream.
The general contract for write(b)
is that it should have exactly the same effect as the call write(b, 0, b.length)
.
write
in class OutputStream
b
- The data array.IOException
- if an I/O error occurs.public void write(byte[] b, int off, int len) throws IOException
Writes len
bytes from the specified byte array starting at offset off
to this output stream.
The general contract for write(b, off, len)
is that some of the bytes in the array b
are written to the output stream in order;
element b[off]
is the first byte written and b[off+len-1]
is the last byte written by this operation.
write
in class OutputStream
b
- The data array.off
- The start offset in the data.len
- The number of bytes to write.IOException
- if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.public void flush() throws IOException
Flushes this output stream and forces any buffered output bytes to be written out.
The general contract of flush
is that calling it is an indication that,
if any bytes previously written have been buffered by the implementation of the output stream,
such bytes should immediately be written to their intended destination.
flush
in interface Flushable
flush
in class OutputStream
IOException
- if an I/O error occurs.public void close() throws IOException
Sets the position of the underlying byte array stream to the beginning.
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
- if an I/O error occurs.public byte[] getByteArray()
Returns the stream content as a byte array.
Copyright © 2022 Aspose. All Rights Reserved.