Class NoSyncBufferedInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
robaho.net.httpserver.NoSyncBufferedInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class NoSyncBufferedInputStream extends FilterInputStream
simple buffered input stream with no synchronization. mark/reset are not supported.
  • Field Details

    • buf

      protected byte[] buf
    • count

      protected int count
      The index one greater than the index of the last valid byte in the buffer. This value is always in the range 0 through buf.length; elements buf[0] through buf[count-1] contain buffered input data obtained from the underlying input stream.
    • pos

      protected int pos
      The current position in the buffer. This is the index of the next byte to be read from the buf array.

      This value is always in the range 0 through count. If it is less than count, then buf[pos] is the next byte to be supplied as input; if it is equal to count, then the next read or skip operation will require more bytes to be read from the contained input stream.

      See Also:
  • Constructor Details

    • NoSyncBufferedInputStream

      public NoSyncBufferedInputStream(InputStream in)
  • Method Details

    • read

      public int read() throws IOException
      See the general contract of the read method of InputStream.
      Overrides:
      read in class FilterInputStream
      Returns:
      the next byte of data, or -1 if the end of the stream is reached.
      Throws:
      IOException - if this input stream has been closed by invoking its close() method, or an I/O error occurs.
      See Also:
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Reads bytes from this byte-input stream into the specified byte array, starting at the given offset.

      This method implements the general contract of the corresponding read method of the InputStream class. As an additional convenience, it attempts to read as many bytes as possible by repeatedly invoking the read method of the underlying stream. This iterated read continues until one of the following conditions becomes true:

      • The specified number of bytes have been read,
      • The read method of the underlying stream returns -1, indicating end-of-file, or
      • The available method of the underlying stream returns zero, indicating that further input requests would block.
      If the first read on the underlying stream returns -1 to indicate end-of-file then this method returns -1. Otherwise, this method returns the number of bytes actually read.

      Subclasses of this class are encouraged, but not required, to attempt to read as many bytes as possible in the same fashion.

      Overrides:
      read in class FilterInputStream
      Parameters:
      b - destination buffer.
      off - offset at which to start storing bytes.
      len - maximum number of bytes to read.
      Returns:
      the number of bytes read, or -1 if the end of the stream has been reached.
    • skip

      public long skip(long n) throws IOException
      See the general contract of the skip method of InputStream.
      Overrides:
      skip in class FilterInputStream
      Throws:
      IOException - if this input stream has been closed by invoking its close() method, in.skip(n) throws an IOException, or an I/O error occurs.
    • available

      public int available() throws IOException
      Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

      Overrides:
      available in class FilterInputStream
      Returns:
      an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking.
      Throws:
      IOException - if this input stream has been closed by invoking its close() method, or an I/O error occurs.
    • close

      public void close() throws IOException
      Closes this input stream and releases any system resources associated with the stream. Once the stream has been closed, further read(), available(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterInputStream
      Throws:
      IOException - if an I/O error occurs.
    • transferTo

      public long transferTo(OutputStream out) throws IOException
      Overrides:
      transferTo in class InputStream
      Throws:
      IOException