com.dropbox.client2
Class DropboxAPI.DropboxInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.dropbox.client2.DropboxAPI.DropboxInputStream
All Implemented Interfaces:
java.io.Closeable
Enclosing class:
DropboxAPI<SESS_T extends Session>

public static class DropboxAPI.DropboxInputStream
extends java.io.FilterInputStream

An InputStream for a file download that includes the associated DropboxAPI.DropboxFileInfo. Closing this stream will cancel the associated download request.


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
DropboxAPI.DropboxInputStream(org.apache.http.client.methods.HttpUriRequest request, org.apache.http.HttpResponse response)
           
 
Method Summary
 void close()
          Closes this stream and aborts the request to Dropbox, releasing any associated resources.
 void copyStreamToOutput(java.io.OutputStream os, ProgressListener listener)
          Copies from a DropboxAPI.DropboxInputStream to an OutputStream, optionally providing updates via a ProgressListener.
 DropboxAPI.DropboxFileInfo getFileInfo()
          Returns the DropboxAPI.DropboxFileInfo for the associated file.
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DropboxAPI.DropboxInputStream

public DropboxAPI.DropboxInputStream(org.apache.http.client.methods.HttpUriRequest request,
                                     org.apache.http.HttpResponse response)
                              throws DropboxException
Throws:
DropboxException
Method Detail

close

public void close()
           throws java.io.IOException
Closes this stream and aborts the request to Dropbox, releasing any associated resources. No more bytes will be downloaded after this is called.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterInputStream
Throws:
java.io.IOException - if an error occurs while closing this stream.

getFileInfo

public DropboxAPI.DropboxFileInfo getFileInfo()
Returns the DropboxAPI.DropboxFileInfo for the associated file.


copyStreamToOutput

public void copyStreamToOutput(java.io.OutputStream os,
                               ProgressListener listener)
                        throws DropboxIOException,
                               DropboxPartialFileException,
                               DropboxLocalStorageFullException
Copies from a DropboxAPI.DropboxInputStream to an OutputStream, optionally providing updates via a ProgressListener. You probably won't have a use for this function because most API functions that return a DropboxAPI.DropboxInputStream have an alternate that will copy to an OutputStream for you.

Parameters:
os - the stream to copy to.
listener - an optional ProgressListener to receive progress updates as the stream is copied, or null.
Throws:
DropboxPartialFileException - if only part of the input stream was copied.
DropboxIOException - for network-related errors.
DropboxLocalStorageFullException - if there is no more room to write to the output stream.
DropboxException - for any other unknown errors. This is also a superclass of all other Dropbox exceptions, so you may want to only catch this exception which signals that some kind of error occurred.