public abstract class BytesWrapper extends Object
SdkBytes
and ResponseBytes
that enables retrieving an underlying byte array as multiple
different types, like a byte buffer (via asByteBuffer()
, or a string (via asUtf8String()
.Modifier and Type | Method and Description |
---|---|
byte[] |
asByteArray() |
byte[] |
asByteArrayUnsafe() |
ByteBuffer |
asByteBuffer() |
ContentStreamProvider |
asContentStreamProvider() |
InputStream |
asInputStream() |
String |
asString(Charset charset)
Retrieve the output as a string.
|
String |
asUtf8String() |
boolean |
equals(Object o) |
int |
hashCode() |
public final ByteBuffer asByteBuffer()
public final byte[] asByteArray()
to prevent creating an additional array copy.
public final byte[] asByteArrayUnsafe()
Consider using asByteBuffer()
, which is a safer method to avoid an additional array copy because it does not
provide a way to modify the underlying buffer. As the method name implies, this is unsafe. If you're not sure, don't use
this. The only guarantees given to the user of this method is that the SDK itself won't modify the underlying byte
array.
to prevent creating an additional array copy safely.
public final String asString(Charset charset) throws UncheckedIOException
charset
- The charset of the string.UncheckedIOException
- with a CharacterCodingException
as the cause if the bytes cannot be encoded using the
provided charsetpublic final String asUtf8String() throws UncheckedIOException
UncheckedIOException
- with a CharacterCodingException
as the cause if the bytes cannot be encoded as UTF-8.public final InputStream asInputStream()
public final ContentStreamProvider asContentStreamProvider()
ContentStreamProvider
.Copyright © 2020. All rights reserved.