Class Bytes


  • public final class Bytes
    extends java.lang.Object
    An immutable byte[] wrapper.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] asNewByteArray()
      Returns a new byte array containing the same content as this object's underlying byte[].
      java.nio.ByteBuffer asReadOnlyByteBuffer()
      Returns a new read-only ByteBuffer backed by this byte array.
      void copyTo​(byte[] destination, int offset, int length)
      Copies this byte array into the provided byte array beginning at offset and up to the provided length.
      boolean equals​(java.lang.Object obj)  
      static Bytes from​(byte[] array)
      Constructs a new Bytes from the provided array.
      static Bytes from​(byte[] array, int offset, int length)
      Constructs a new Bytes read from provided offset for the provided length.
      static Bytes from​(java.nio.ByteBuffer buffer)
      Constructs a new Bytes read from the provided ByteBuffer.
      java.io.InputStream getInputStream()
      Returns a new InputStream that reads this byte array.
      int hashCode()  
      int size()
      Returns the size of this byte array.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • asReadOnlyByteBuffer

        public java.nio.ByteBuffer asReadOnlyByteBuffer()
        Returns a new read-only ByteBuffer backed by this byte array.
      • asNewByteArray

        public byte[] asNewByteArray()
        Returns a new byte array containing the same content as this object's underlying byte[].
      • copyTo

        public void copyTo​(byte[] destination,
                           int offset,
                           int length)
        Copies this byte array into the provided byte array beginning at offset and up to the provided length.
      • getInputStream

        public java.io.InputStream getInputStream()
        Returns a new InputStream that reads this byte array.
      • size

        public int size()
        Returns the size of this byte array.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • from

        public static Bytes from​(byte[] array)
        Constructs a new Bytes from the provided array.
      • from

        public static Bytes from​(byte[] array,
                                 int offset,
                                 int length)
        Constructs a new Bytes read from provided offset for the provided length.
      • from

        public static Bytes from​(java.nio.ByteBuffer buffer)
        Constructs a new Bytes read from the provided ByteBuffer.