This class implements an output stream in which the data is written into a byte array. The buffer automatically grows as data is written to it. The data can be retrieved using toByteArray() and toString().
Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
This class implements an output stream in which the data is written into a byte array. The buffer automatically grows as data is written to it. The data can be retrieved using toByteArray() and toString(). Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
(->byte-array-output-stream)
(->byte-array-output-stream size)
Constructor.
Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.
size - the initial size. - int
throws: java.lang.IllegalArgumentException - if size is negative.
Constructor. Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes. size - the initial size. - `int` throws: java.lang.IllegalArgumentException - if size is negative.
(close this)
Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
throws: java.io.IOException - if an I/O error occurs.
Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException. throws: java.io.IOException - if an I/O error occurs.
(reset this)
Resets the 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.
Resets the 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.
(size this)
Returns the current size of the buffer.
returns: the value of the count field, which is the number
of valid bytes in this output stream. - int
Returns the current size of the buffer. returns: the value of the count field, which is the number of valid bytes in this output stream. - `int`
(to-byte-array this)
Creates a newly allocated byte array. Its size is the current size of this output stream and the valid contents of the buffer have been copied into it.
returns: the current contents of this output stream, as a byte array. - byte[]
Creates a newly allocated byte array. Its size is the current size of this output stream and the valid contents of the buffer have been copied into it. returns: the current contents of this output stream, as a byte array. - `byte[]`
(to-string this)
(to-string this charset-name)
Converts the buffer's contents into a string by decoding the bytes using the named 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.
charset-name - the name of a supported charset - java.lang.String
returns: String decoded from the buffer's contents. - java.lang.String
throws: java.io.UnsupportedEncodingException - If the named charset is not supported
Converts the buffer's contents into a string by decoding the bytes using the named 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. charset-name - the name of a supported charset - `java.lang.String` returns: String decoded from the buffer's contents. - `java.lang.String` throws: java.io.UnsupportedEncodingException - If the named charset is not supported
(write this b)
(write this b off len)
Writes len bytes from the specified byte array starting at offset off to this byte array output stream.
b - the data. - byte[]
off - the start offset in the data. - int
len - the number of bytes to write. - int
Writes len bytes from the specified byte array starting at offset off to this byte array output stream. b - the data. - `byte[]` off - the start offset in the data. - `int` len - the number of bytes to write. - `int`
(write-to this 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).
out - the output stream to which to write the data. - java.io.OutputStream
throws: java.io.IOException - if an I/O error occurs.
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). out - the output stream to which to write the data. - `java.io.OutputStream` throws: java.io.IOException - if an I/O error occurs.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close