Class ChunkInputStreamOptionalBuffer
java.lang.Object
java.io.InputStream
io.clonecloudstore.common.quarkus.stream.ChunkInputStreamOptionalBuffer
- All Implemented Interfaces:
ChunkInputStreamInterface,Closeable,AutoCloseable
public class ChunkInputStreamOptionalBuffer
extends InputStream
implements ChunkInputStreamInterface
Transform one InputStream to Multiple InputStream, each one being a chunk of the primary one.
Note that if length is not provided, chunk size will be the buffer size used internally, so the buffer size will be reduced to 512 MB for memory capacity handling. Inversely, if length is provided, no buffer will be allocated.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionChunkInputStreamOptionalBuffer(InputStream inputStream, long len, int chunkSize) -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()longlongintlongbooleanbooleanbooleanintread()intread(byte[] b, int off, int len) longskip(long len) longtransferTo(OutputStream out) Methods inherited from class java.io.InputStream
mark, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skipNBytes
-
Field Details
-
MIN_CHUNK_SIZE
public static final int MIN_CHUNK_SIZE- See Also:
-
maxChunkSize
public final int maxChunkSize
-
-
Constructor Details
-
ChunkInputStreamOptionalBuffer
- Parameters:
inputStream- the InputStream to split as multiple InputStream by chunklen- the real InputStream size; if 0, chunk size will be the buffer size usedchunkSize- the chunk size to split on
-
-
Method Details
-
nextChunk
- Specified by:
nextChunkin interfaceChunkInputStreamInterface- Returns:
- True if the next Chunk of InputStream is ready, else implies closing of native InputStream
- Throws:
IOException- if an issue occurs
-
isChunksDone
public boolean isChunksDone()- Specified by:
isChunksDonein interfaceChunkInputStreamInterface- Returns:
- True if all chunks are done
-
getAvailableChunkSize
public long getAvailableChunkSize()- Specified by:
getAvailableChunkSizein interfaceChunkInputStreamInterface- Returns:
- if known, the chunk size currently available, else -1
-
getChunkSize
public long getChunkSize()- Specified by:
getChunkSizein interfaceChunkInputStreamInterface- Returns:
- the current chunk size
-
getCurrentPos
public int getCurrentPos()- Specified by:
getCurrentPosin interfaceChunkInputStreamInterface- Returns:
- the current position in the buffer
-
getCurrentTotalRead
public long getCurrentTotalRead()- Specified by:
getCurrentTotalReadin interfaceChunkInputStreamInterface- Returns:
- the total number of read bytes
-
read
- Specified by:
readin interfaceChunkInputStreamInterface- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Specified by:
readin interfaceChunkInputStreamInterface- Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Specified by:
skipin interfaceChunkInputStreamInterface- Overrides:
skipin classInputStream- Throws:
IOException
-
available
- Specified by:
availablein interfaceChunkInputStreamInterface- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChunkInputStreamInterface- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Specified by:
markSupportedin interfaceChunkInputStreamInterface- Overrides:
markSupportedin classInputStream
-
transferTo
- Specified by:
transferToin interfaceChunkInputStreamInterface- Overrides:
transferToin classInputStream- Throws:
IOException
-