Class ByteBuffer

java.lang.Object
com.itextpdf.kernel.xmp.impl.ByteBuffer

public class ByteBuffer extends Object
Byte buffer container including length of valid data.
Since:
11.10.2006
  • Constructor Details

    • ByteBuffer

      public ByteBuffer (int initialCapacity)
      Parameters:
      initialCapacity - the initial capacity for this buffer
    • ByteBuffer

      public ByteBuffer (byte[] buffer)
      Parameters:
      buffer - a byte array that will be wrapped with ByteBuffer.
    • ByteBuffer

      public ByteBuffer (byte[] buffer, int length)
      Parameters:
      buffer - a byte array that will be wrapped with ByteBuffer.
      length - the length of valid bytes in the array
    • ByteBuffer

      public ByteBuffer (InputStream in) throws IOException
      Loads the stream into a buffer.
      Parameters:
      in - an InputStream
      Throws:
      IOException - If the stream cannot be read.
    • ByteBuffer

      public ByteBuffer (byte[] buffer, int offset, int length)
      Parameters:
      buffer - a byte array that will be wrapped with ByteBuffer.
      offset - the offset of the provided buffer.
      length - the length of valid bytes in the array
  • Method Details

    • getByteStream

      public InputStream getByteStream()
      Returns:
      Returns a byte stream that is limited to the valid amount of bytes.
    • length

      public int length()
      Returns:
      Returns the length, that means the number of valid bytes, of the buffer; the inner byte array might be bigger than that.
    • byteAt

      public byte byteAt (int index)
      Parameters:
      index - the index to retrieve the byte from
      Returns:
      Returns a byte from the buffer
    • charAt

      public int charAt (int index)
      Parameters:
      index - the index to retrieve a byte as int or char.
      Returns:
      Returns a byte from the buffer
    • append

      public void append (byte b)
      Appends a byte to the buffer.
      Parameters:
      b - a byte
    • append

      public void append (byte[] bytes, int offset, int len)
      Appends a part of byte array to the buffer. Elements on positions offset through offset+len-1 of provided array will be copied
      Parameters:
      bytes - a byte array
      offset - is a position of the first element to copy
      len - the number of array elements to be added
    • append

      public void append (byte[] bytes)
      Append a byte array to the buffer
      Parameters:
      bytes - a byte array
    • append

      public void append (ByteBuffer anotherBuffer)
      Append another buffer to this buffer.
      Parameters:
      anotherBuffer - another ByteBuffer
    • getEncoding

      public String getEncoding()
      Detects the encoding of the byte buffer, stores and returns it. Only UTF-8, UTF-16LE/BE and UTF-32LE/BE are recognized. Note: UTF-32 flavors are not supported by Java, the XML-parser will complain.
      Returns:
      Returns the encoding string.