Package org.apache.commons.fileupload
Class MultipartStream.ItemInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.fileupload.MultipartStream.ItemInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,Closeable
- Enclosing class:
MultipartStream
An
InputStream for reading an items contents.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intOffset when converting negative bytes to integers.private booleanWhether the stream is already closed.private intThe number of bytes, which must be hold, because they might be a part of the boundary.private intThe current offset in the buffer.private longThe number of bytes, which have been read so far. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of bytes, which are currently available, without blocking.voidclose()Closes the input stream.voidclose(boolean closeUnderlying) Closes the input stream.private voidCalled for finding the separator.longReturns the number of bytes, which have been read by the stream.booleanisClosed()Returns, whether the stream is closed.private intAttempts to read more data.intread()Returns the next byte in the stream.intread(byte[] b, int off, int len) Reads bytes into the given buffer.longskip(long bytes) Skips the given number of bytes.Methods inherited from class java.io.InputStream
mark, markSupported, read, reset
-
Field Details
-
BYTE_POSITIVE_OFFSET
private static final int BYTE_POSITIVE_OFFSETOffset when converting negative bytes to integers.- See Also:
-
total
private long totalThe number of bytes, which have been read so far. -
pad
private int padThe number of bytes, which must be hold, because they might be a part of the boundary. -
pos
private int posThe current offset in the buffer. -
closed
private boolean closedWhether the stream is already closed.
-
-
Constructor Details
-
ItemInputStream
ItemInputStream()Creates a new instance.
-
-
Method Details
-
available
Returns the number of bytes, which are currently available, without blocking.- Overrides:
availablein classInputStream- Returns:
- Number of bytes in the buffer.
- Throws:
IOException- An I/O error occurs.
-
close
Closes the input stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException- An I/O error occurred.
-
close
Closes the input stream.- Parameters:
closeUnderlying- Whether to close the underlying stream (hard close)- Throws:
IOException- An I/O error occurred.
-
findSeparator
private void findSeparator()Called for finding the separator. -
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.
-
isClosed
public boolean isClosed()Returns, whether the stream is closed. -
makeAvailable
Attempts to read more data.- Returns:
- Number of available bytes
- Throws:
IOException- An I/O error occurred.
-
read
Returns the next byte in the stream.- Specified by:
readin 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
Reads bytes into the given buffer.- Overrides:
readin 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.
-
skip
Skips the given number of bytes.- Overrides:
skipin 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.
-