JavaScript is disabled on your browser.
Skip navigation links

AWS SDK for Java 1.x API Reference - 1.12.795

We announced the upcoming end-of-support for AWS SDK for Java (v1). We recommend that you migrate to AWS SDK for Java v2. For dates, additional details, and information on how to migrate, please refer to the linked announcement.
com.amazonaws.util

Class BinaryUtils



  • public class BinaryUtils
    extends Object 
    Utilities for encoding and decoding binary data to and from different forms.
    • Constructor Summary

      Constructors
      Constructor and Description
      BinaryUtils ()
    • Method Summary

      All Methods
      Modifier and Type Method and Description
      static byte[] copyAllBytesFrom (ByteBuffer bb)
      Returns a copy of all the bytes from the given ByteBuffer, from the beginning to the buffer's limit; or null if the input is null.
      static byte[] copyBytesFrom (ByteBuffer bb)
      Returns a copy of the bytes from the given ByteBuffer, ranging from the the buffer's current position to the buffer's limit; or null if the input is null.
      static byte[] fromBase64 (String b64Data)
      Converts a Base64-encoded string to the original byte data.
      static byte[] fromHex (String hexData)
      Converts a Hex-encoded data string to the original byte data.
      static String toBase64 (byte[] data)
      Converts byte data to a Base64-encoded string.
      static String toHex (byte[] data)
      Converts byte data to a Hex-encoded string in lower case.
      static ByteArrayInputStream toStream (ByteBuffer byteBuffer)
      Wraps a ByteBuffer in an InputStream.
    • Constructor Detail

      • BinaryUtils

        public BinaryUtils()
    • Method Detail

      • toHex

        public static String toHex(byte[] data)
        Converts byte data to a Hex-encoded string in lower case.
        Parameters:
        data - data to hex encode.
        Returns:
        hex-encoded string.
      • fromHex

        public static byte[] fromHex(String hexData)
        Converts a Hex-encoded data string to the original byte data.
        Parameters:
        hexData - hex-encoded data to decode.
        Returns:
        decoded data from the hex string.
      • toBase64

        public static String toBase64(byte[] data)
        Converts byte data to a Base64-encoded string.
        Parameters:
        data - data to Base64 encode.
        Returns:
        encoded Base64 string.
      • fromBase64

        public static byte[] fromBase64(String b64Data)
        Converts a Base64-encoded string to the original byte data.
        Parameters:
        b64Data - a Base64-encoded string to decode.
        Returns:
        bytes decoded from a Base64 string.
      • toStream

        public static ByteArrayInputStream toStream(ByteBuffer byteBuffer)
        Wraps a ByteBuffer in an InputStream. If the input byteBuffer is null, returns an empty stream.
        Parameters:
        byteBuffer - The ByteBuffer to wrap.
        Returns:
        An InputStream wrapping the ByteBuffer content.
      • copyAllBytesFrom

        public static byte[] copyAllBytesFrom(ByteBuffer bb)
        Returns a copy of all the bytes from the given ByteBuffer, from the beginning to the buffer's limit; or null if the input is null.

        The internal states of the given byte buffer will be restored when this method completes execution.

        When handling ByteBuffer from user's input, it's typical to call the copyBytesFrom(ByteBuffer) instead of copyAllBytesFrom(ByteBuffer) so as to account for the position of the input ByteBuffer. The opposite is typically true, however, when handling ByteBuffer from withint the unmarshallers of the low-level clients.

      • copyBytesFrom

        public static byte[] copyBytesFrom(ByteBuffer bb)
        Returns a copy of the bytes from the given ByteBuffer, ranging from the the buffer's current position to the buffer's limit; or null if the input is null.

        The internal states of the given byte buffer will be restored when this method completes execution.

        When handling ByteBuffer from user's input, it's typical to call the copyBytesFrom(ByteBuffer) instead of copyAllBytesFrom(ByteBuffer) so as to account for the position of the input ByteBuffer. The opposite is typically true, however, when handling ByteBuffer from withint the unmarshallers of the low-level clients.

Skip navigation links

AltStyle によって変換されたページ (->オリジナル) /