Package software.amazon.awssdk.core
Class SdkBytes
- java.lang.Object
-
- software.amazon.awssdk.core.BytesWrapper
-
- software.amazon.awssdk.core.SdkBytes
-
- All Implemented Interfaces:
Serializable
public final class SdkBytes extends BytesWrapper implements Serializable
An in-memory representation of data being given to a service or being returned by a service. This can be created via static methods, likefromByteArray(byte[])
. This can be converted to binary types via instance methods, likeBytesWrapper.asByteArray()
.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SdkBytes
fromByteArray(byte[] bytes)
CreateSdkBytes
from a Byte array.static SdkBytes
fromByteArrayUnsafe(byte[] bytes)
CreateSdkBytes
from a Byte array without copying the contents of the byte array.static SdkBytes
fromByteBuffer(ByteBuffer byteBuffer)
CreateSdkBytes
from a Byte buffer.static SdkBytes
fromInputStream(InputStream inputStream)
CreateSdkBytes
from an input stream.static SdkBytes
fromString(String string, Charset charset)
CreateSdkBytes
from a string, using the provided charset.static SdkBytes
fromUtf8String(String string)
CreateSdkBytes
from a string, using the UTF-8 charset.String
toString()
-
Methods inherited from class software.amazon.awssdk.core.BytesWrapper
asByteArray, asByteArrayUnsafe, asByteBuffer, asContentStreamProvider, asInputStream, asString, asUtf8String, equals, hashCode
-
-
-
-
Method Detail
-
fromByteBuffer
public static SdkBytes fromByteBuffer(ByteBuffer byteBuffer)
CreateSdkBytes
from a Byte buffer. This will read the remaining contents of the byte buffer.
-
fromByteArray
public static SdkBytes fromByteArray(byte[] bytes)
CreateSdkBytes
from a Byte array. This will copy the contents of the byte array.
-
fromByteArrayUnsafe
public static SdkBytes fromByteArrayUnsafe(byte[] bytes)
CreateSdkBytes
from a Byte array without copying the contents of the byte array. This introduces concurrency risks, allowing: (1) the caller to modify the byte array stored in thisSdkBytes
implementation AND (2) any users ofBytesWrapper.asByteArrayUnsafe()
to modify the byte array passed into thisSdkBytes
implementation.As the method name implies, this is unsafe. Use
fromByteArray(byte[])
unless you're sure you know the risks.
-
fromString
public static SdkBytes fromString(String string, Charset charset)
CreateSdkBytes
from a string, using the provided charset.
-
fromUtf8String
public static SdkBytes fromUtf8String(String string)
CreateSdkBytes
from a string, using the UTF-8 charset.
-
fromInputStream
public static SdkBytes fromInputStream(InputStream inputStream)
CreateSdkBytes
from an input stream. This will read all of the remaining contents of the stream, but will not close it.
-
-