Package de.uhilger.httpserver.up
Class MultipartStream.ItemInputStream
- java.lang.Object
-
- java.io.InputStream
-
- de.uhilger.httpserver.up.MultipartStream.ItemInputStream
-
- All Implemented Interfaces:
Closeable
,Closeable
,AutoCloseable
- Enclosing class:
- MultipartStream
public class MultipartStream.ItemInputStream extends InputStream implements Closeable
AnInputStream
for reading an items contents.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
Returns the number of bytes, which are currently available, without blocking.void
close()
Closes the input stream.void
close(boolean pCloseUnderlying)
Closes the input stream.long
getBytesRead()
Returns the number of bytes, which have been read by the stream.boolean
isClosed()
Returns, whether the stream is closed.int
read()
Returns the next byte in the stream.int
read(byte[] b, int off, int len)
Reads bytes into the given buffer.long
skip(long bytes)
Skips the given number of bytes.-
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, transferTo
-
-
-
-
Method Detail
-
getBytesRead
public long getBytesRead()
Returns the number of bytes, which have been read by the stream.- Returns:
- Number of bytes, which have been read so far.
-
available
public int available() throws IOException
Returns the number of bytes, which are currently available, without blocking.- Overrides:
available
in classInputStream
- Returns:
- Number of bytes in the buffer.
- Throws:
IOException
- An I/O error occurs.
-
read
public int read() throws IOException
Returns the next byte in the stream.- Specified by:
read
in classInputStream
- Returns:
- The next byte in the stream, as a non-negative integer, or -1 for EOF.
- Throws:
IOException
- An I/O error occurred.
-
read
public int read(byte[] b, int off, int len) throws IOException
Reads bytes into the given buffer.- Overrides:
read
in classInputStream
- Parameters:
b
- The destination buffer, where to write to.off
- Offset of the first byte in the buffer.len
- Maximum number of bytes to read.- Returns:
- Number of bytes, which have been actually read, or -1 for EOF.
- Throws:
IOException
- An I/O error occurred.
-
close
public void close() throws IOException
Closes the input stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
- An I/O error occurred.
-
close
public void close(boolean pCloseUnderlying) throws IOException
Closes the input stream.- Parameters:
pCloseUnderlying
- Whether to close the underlying stream (hard close)- Throws:
IOException
- An I/O error occurred.
-
skip
public long skip(long bytes) throws IOException
Skips the given number of bytes.- Overrides:
skip
in classInputStream
- Parameters:
bytes
- Number of bytes to skip.- Returns:
- The number of bytes, which have actually been skipped.
- Throws:
IOException
- An I/O error occurred.
-
-