Class ByteBuffer

java.lang.Object
java.io.OutputStream
com.aowagie.text.pdf.ByteBuffer
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class ByteBuffer extends OutputStream
Acts like a StringBuffer but works with byte arrays. Floating point is converted to a format suitable to the PDF.
Author:
Paulo Soares (psoares@consiste.pt)
  • Constructor Details

    • ByteBuffer

      public ByteBuffer()
      Creates new ByteBuffer with capacity 128
    • ByteBuffer

      public ByteBuffer(int size)
      Creates a byte buffer with a certain capacity.
      Parameters:
      size - the initial capacity
  • Method Details

    • append_i

      public ByteBuffer append_i(int b)
      Appends an int. The size of the array will grow by one.
      Parameters:
      b - the int to be appended
      Returns:
      a reference to this ByteBuffer object
    • append

      public ByteBuffer append(byte b)
    • toByteArray

      public byte[] toByteArray()
      Creates a newly allocated byte array. Its size is the current size of this output stream and the valid contents of the buffer have been copied into it.
      Returns:
      the current contents of this output stream, as a byte array.
    • setSize

      public void setSize(int size)
    • toString

      public String toString()
      Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.
      Overrides:
      toString in class Object
      Returns:
      String translated from the buffer's contents.
    • write

      public void write(int b) throws IOException
      Specified by:
      write in class OutputStream
      Throws:
      IOException
    • write

      public void write(byte[] b, int off, int len)
      Overrides:
      write in class OutputStream
    • getBuffer

      public byte[] getBuffer()