Class MultipartRequestInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
jodd.http.upload.MultipartRequestInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Extended input stream based on buffered requests input stream.
It provides some more functions that might be useful when working
with uploaded fies.
-
Field Summary
FieldsFields inherited from class FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcopyAll(OutputStream out) Copies bytes from this stream to some output until boundary is reached.intcopyMax(OutputStream out, int maxBytes) Copies max or less number of bytes to output stream.booleanisBoundary(byte b) Checks if the current byte (i.e.byte[]Reads boundary from the input stream.bytereadByte()Reads expected byte.readDataHeader(String encoding) Reads data header from the input stream.protected StringreadDataHeaderString(String encoding) voidskipBytes(int i) Skips specified number of bytes.intSkips to the boundary and returns total number of bytes skipped.Methods inherited from class BufferedInputStream
available, close, mark, markSupported, read, read, reset, skip, transferToMethods inherited from class FilterInputStream
readMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes
-
Field Details
-
boundary
protected byte[] boundary -
lastHeader
-
-
Constructor Details
-
MultipartRequestInputStream
-
-
Method Details
-
readByte
Reads expected byte. Throws exception on streams end.- Throws:
IOException
-
skipBytes
Skips specified number of bytes.- Throws:
IOException
-
readBoundary
Reads boundary from the input stream.- Throws:
IOException
-
getLastHeader
-
readDataHeader
Reads data header from the input stream. When there is no more headers (i.e. end of stream reached), returnsnull- Throws:
IOException
-
readDataHeaderString
- Throws:
IOException
-
copyAll
Copies bytes from this stream to some output until boundary is reached. Returns number of copied bytes. It will throw an exception for any irregular behaviour.- Throws:
IOException
-
copyMax
Copies max or less number of bytes to output stream. Useful for determining if uploaded file is larger then expected.- Throws:
IOException
-
skipToBoundary
Skips to the boundary and returns total number of bytes skipped.- Throws:
IOException
-
isBoundary
Checks if the current byte (i.e. one that was read last) represents the very first byte of the boundary.- Throws:
IOException
-