Package com.mongodb.client.gridfs
Class GridFSDownloadStream
- java.lang.Object
-
- java.io.InputStream
-
- com.mongodb.client.gridfs.GridFSDownloadStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
@NotThreadSafe public abstract class GridFSDownloadStream extends InputStream
A GridFS InputStream for downloading data from GridFSProvides the
GridFSFilefor the file to being downloaded as well as thereadmethods of aInputStreamThis implementation of a
InputStreamwill not throwIOExceptions. However, it will throw aMongoExceptionif there is an error reading from MongoDB.- Since:
- 3.1
-
-
Constructor Summary
Constructors Constructor Description GridFSDownloadStream()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract intavailable()abstract GridFSDownloadStreambatchSize(int batchSize)Sets the number of chunks to return per batch.abstract voidclose()abstract GridFSFilegetGridFSFile()Gets the correspondingGridFSFilefor the file being downloadedabstract voidmark()Marks the current position in this input stream.abstract intread()abstract intread(byte[] b)abstract intread(byte[] b, int off, int len)abstract voidreset()abstract longskip(long n)-
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Method Detail
-
getGridFSFile
public abstract GridFSFile getGridFSFile()
Gets the correspondingGridFSFilefor the file being downloaded- Returns:
- the corresponding GridFSFile for the file being downloaded
-
batchSize
public abstract GridFSDownloadStream batchSize(int batchSize)
Sets the number of chunks to return per batch.Can be used to control the memory consumption of this InputStream. The smaller the batchSize the lower the memory consumption and higher latency.
- Parameters:
batchSize- the batch size- Returns:
- this
- MongoDB documentation
- Batch Size
-
read
public abstract int read()
- Specified by:
readin classInputStream
-
read
public abstract int read(byte[] b)
- Overrides:
readin classInputStream
-
read
public abstract int read(byte[] b, int off, int len)- Overrides:
readin classInputStream
-
skip
public abstract long skip(long n)
- Overrides:
skipin classInputStream
-
available
public abstract int available()
- Overrides:
availablein classInputStream
-
mark
public abstract void mark()
Marks the current position in this input stream.A subsequent call to the
resetmethod repositions this stream at the last marked position so that subsequent reads re-read the same bytes.
-
reset
public abstract void reset()
- Overrides:
resetin classInputStream
-
close
public abstract void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream
-
-