java.lang.Object
java.io.InputStream
java.io.FilterInputStream
robaho.net.httpserver.NoSyncBufferedInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
simple buffered input stream with no synchronization. mark/reset are not supported.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]protected intThe index one greater than the index of the last valid byte in the buffer.protected intThe current position in the buffer.Fields inherited from class java.io.FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns 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.voidclose()Closes this input stream and releases any system resources associated with the stream.intread()See the general contract of thereadmethod ofInputStream.intread(byte[] b, int off, int len) Reads bytes from this byte-input stream into the specified byte array, starting at the given offset.longskip(long n) See the general contract of theskipmethod ofInputStream.longtransferTo(OutputStream out) Methods inherited from class java.io.FilterInputStream
mark, markSupported, read, resetMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes
-
Field Details
-
buf
protected byte[] buf -
count
protected int countThe index one greater than the index of the last valid byte in the buffer. This value is always in the range0throughbuf.length; elementsbuf[0]throughbuf[count-1]contain buffered input data obtained from the underlying input stream. -
pos
protected int posThe current position in the buffer. This is the index of the next byte to be read from thebufarray.This value is always in the range
0throughcount. If it is less thancount, thenbuf[pos]is the next byte to be supplied as input; if it is equal tocount, then the nextreadorskipoperation will require more bytes to be read from the contained input stream.- See Also:
-
-
Constructor Details
-
NoSyncBufferedInputStream
-
-
Method Details
-
read
See the general contract of thereadmethod ofInputStream.- Overrides:
readin classFilterInputStream- Returns:
- the next byte of data, or
-1if the end of the stream is reached. - Throws:
IOException- if this input stream has been closed by invoking itsclose()method, or an I/O error occurs.- See Also:
-
read
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
readmethod of theInputStreamclass. As an additional convenience, it attempts to read as many bytes as possible by repeatedly invoking thereadmethod of the underlying stream. This iteratedreadcontinues until one of the following conditions becomes true:- The specified number of bytes have been read,
- The
readmethod of the underlying stream returns-1, indicating end-of-file, or - The
availablemethod of the underlying stream returns zero, indicating that further input requests would block.
readon the underlying stream returns-1to 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:
readin classFilterInputStream- 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
-1if the end of the stream has been reached.
-
skip
See the general contract of theskipmethod ofInputStream.- Overrides:
skipin classFilterInputStream- Throws:
IOException- if this input stream has been closed by invoking itsclose()method,in.skip(n)throws an IOException, or an I/O error occurs.
-
available
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:
availablein classFilterInputStream- 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 itsclose()method, or an I/O error occurs.
-
close
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException- if an I/O error occurs.
-
transferTo
- Overrides:
transferToin classInputStream- Throws:
IOException
-