public interface Bytes
This interface provides access to copies of the binary data, making instances effectively immutable. Methods of derived interfaces and classes that relax this restriction and expose access to the internal data should be clearly documented.
Modifier and Type | Method and Description |
---|---|
InputStream |
asInputStream()
Returns a stream that provides the data.
|
void |
copyTo(OutputStream target)
Write the bytes to an output stream.
|
int |
length() |
byte[] |
toByteArray()
Returns a copy of the data as a byte array.
|
int length()
InputStream asInputStream()
Bytes
. This minimises copying
at the expense of retaining potentially inaccessible data for
longer.byte[] toByteArray()
void copyTo(OutputStream target) throws IOException
This method avoids the allocation and copying costs of producing an
intermediate byte array
.
target
- the target output streamIOException
- if writing to target causes an I/O errorCopyright © 2024 DiffusionData Ltd. All Rights Reserved.