Class LimitedByteBuffer


  • public class LimitedByteBuffer
    extends java.lang.Object
    Class for accumulating bytes into an automatically expanding buffer with an explicit upper limit to the size
    • Constructor Summary

      Constructors 
      Constructor Description
      LimitedByteBuffer​(int initial, int amax)
      Create the buffer specifying its initial and limiting capacity
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void append​(byte b)
      Append a byte into the buffer.
      java.io.ByteArrayInputStream getInputStream()
      Generate an InputStream from the bytes that have been appended to the buffer The buffer is NOT copied
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • LimitedByteBuffer

        public LimitedByteBuffer​(int initial,
                                 int amax)
        Create the buffer specifying its initial and limiting capacity
        Parameters:
        initial - is the number of bytes to be initially allocated for the buffer
        amax - is the absolute maximum number of bytes the buffer is allowed to expand to before throwing exceptions
    • Method Detail

      • append

        public void append​(byte b)
                    throws java.io.IOException
        Append a byte into the buffer. The buffer's internal storage is expanded as necessary, but only up to the specified maximum. If this append exceeds that maximum, then an exception is thrown
        Parameters:
        b - is the byte to append
        Throws:
        java.io.IOException
      • getInputStream

        public java.io.ByteArrayInputStream getInputStream()
        Generate an InputStream from the bytes that have been appended to the buffer The buffer is NOT copied
        Returns:
        the new InputStream
      • toString

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