Class ByteBufferUtils

java.lang.Object
io.stargate.sgv2.api.common.util.ByteBufferUtils

public class ByteBufferUtils extends Object
Author:
Dmitri Bourlatchkov
  • Method Details

    • toBase64

      public static String toBase64(ByteBuffer buffer)
    • toBase64

      public static String toBase64(byte[] bytes)
    • fromBase64

      public static ByteBuffer fromBase64(String base64)
    • toBase64ForUrl

      public static String toBase64ForUrl(ByteBuffer buffer)
    • toBase64ForUrl

      public static String toBase64ForUrl(byte[] bytes)
    • fromBase64UrlParam

      public static ByteBuffer fromBase64UrlParam(String base64)
    • getArray

      public static byte[] getArray(ByteBuffer bytes)
      Extract the content of the provided ByteBuffer as a byte array.

      This method work with any type of ByteBuffer (direct and non-direct ones), but when the ByteBuffer is backed by an array, this method will try to avoid copy when possible. As a consequence, changes to the returned byte array may or may not reflect into the initial ByteBuffer.

      Parameters:
      bytes - the buffer whose content to extract.
      Returns:
      a byte array with the content of bytes. That array may be the array backing bytes if this can avoid a copy.