Class GridFSDownloadStream

  • All Implemented Interfaces:
    ,

    @NotThreadSafe
    public abstract class GridFSDownloadStream
    extends 
    A GridFS InputStream for downloading data from GridFS

    Provides the GridFSFile for the file to being downloaded as well as the read methods of a

    This implementation of a InputStream will not throw s. However, it will throw a MongoException if there is an error reading from MongoDB.

    Since:
    3.1
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract int available()  
      abstract GridFSDownloadStream batchSize​(int batchSize)
      Sets the number of chunks to return per batch.
      abstract void close()  
      abstract GridFSFile getGridFSFile()
      Gets the corresponding GridFSFile for the file being downloaded
      abstract void mark()
      Marks the current position in this input stream.
      abstract int read()  
      abstract int read​(byte[] b)  
      abstract int read​(byte[] b, int off, int len)  
      abstract void reset()  
      abstract long skip​(long n)  
      • Methods inherited from class java.io.

        , , , , , ,
      • Methods inherited from class java.lang.

        , , , , , , , , , ,
    • Constructor Detail

      • GridFSDownloadStream

        public GridFSDownloadStream()
    • Method Detail

      • getGridFSFile

        public abstract GridFSFile getGridFSFile()
        Gets the corresponding GridFSFile for 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
      • read

        public abstract int read()
        Specified by:
         in class 
      • read

        public abstract int read​(byte[] b)
        Overrides:
         in class 
      • read

        public abstract int read​(byte[] b,
                                 int off,
                                 int len)
        Overrides:
         in class 
      • skip

        public abstract long skip​(long n)
        Overrides:
         in class 
      • available

        public abstract int available()
        Overrides:
         in class 
      • mark

        public abstract void mark()
        Marks the current position in this input stream.

        A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

      • reset

        public abstract void reset()
        Overrides:
         in class 
      • close

        public abstract void close()
        Specified by:
         in interface 
        Specified by:
         in interface 
        Overrides:
         in class