Class UnsafeInput

  • All Implemented Interfaces:
    Pool.Poolable, Closeable, AutoCloseable

    public class UnsafeInput
    extends Input
    An Input that reads data from a byte[] using sun.misc.Unsafe. Multi-byte primitive types use native byte order, so the native byte order on different computers which read and write the data must be the same.

    Not available on all JVMs. Util.unsafe can be checked before using this class.

    This class may be much faster when Input.setVariableLengthEncoding(boolean) is false.

    Author:
    Roman Levenstein , Nathan Sweet
    • Constructor Detail

      • UnsafeInput

        public UnsafeInput()
        Creates an uninitialized Input, Input.setBuffer(byte[]) must be called before the Input is used.
      • UnsafeInput

        public UnsafeInput​(int bufferSize)
        Creates a new Input for reading from a byte[] buffer.
        Parameters:
        bufferSize - The size of the buffer. An exception is thrown if more bytes than this are read and Input.fill(byte[], int, int) does not supply more bytes.
      • UnsafeInput

        public UnsafeInput​(byte[] buffer)
        Creates a new Input for reading from a byte[] buffer.
        Parameters:
        buffer - An exception is thrown if more bytes than this are read and Input.fill(byte[], int, int) does not supply more bytes.
      • UnsafeInput

        public UnsafeInput​(byte[] buffer,
                           int offset,
                           int count)
        Creates a new Input for reading from a byte[] buffer.
        Parameters:
        buffer - An exception is thrown if more bytes than this are read and Input.fill(byte[], int, int) does not supply more bytes.
      • UnsafeInput

        public UnsafeInput​(InputStream inputStream)
        Creates a new Input for reading from an InputStream with a buffer size of 4096.
      • UnsafeInput

        public UnsafeInput​(InputStream inputStream,
                           int bufferSize)
        Creates a new Input for reading from an InputStream with the specified buffer size.