public interface IByteArrayOutputStream extends IOutputStream
ByteArrayOutputStream
-representing interface to be used in API contracts.
See IOutputStream
for further details.
Modifier and Type | Method and Description |
---|---|
void |
reset()
Resets the
count field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. |
int |
size()
Returns the current size of the buffer.
|
byte[] |
toByteArray()
Creates a newly allocated byte array.
|
String |
toString(String charsetName)
Converts the buffer's contents into a string by decoding the bytes using
the named
charset . |
void |
writeTo(IOutputStream out)
Writes the complete contents of this byte array output stream to
the specified output stream argument, as if by calling the output
stream's write method using
out.write(buf, 0, count) . |
void writeTo(IOutputStream out) throws IOException
out.write(buf, 0, count)
.out
- the output stream to which to write the data.IOException
- if an I/O error occurs.void reset()
count
field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. The output stream can be used again,
reusing the already allocated buffer space.ByteArrayInputStream.count
byte[] toByteArray()
ByteArrayOutputStream.size()
int size()
count
field, which is the number
of valid bytes in this output stream.ByteArrayOutputStream.count
String toString(String charsetName) throws UnsupportedEncodingException
charset
. The length of the new
String is a function of the charset, and hence may not be equal
to the length of the byte array.
This method always replaces malformed-input and unmappable-character
sequences with this charset's default replacement string. The CharsetDecoder
class should be used when more control
over the decoding process is required.
charsetName
- the name of a supported
charset
UnsupportedEncodingException
- If the named charset is not supportedCopyright © 2013–2019. All rights reserved.