Class IncomingFileTransfer
- java.lang.Object
-
- org.jivesoftware.smackx.filetransfer.FileTransfer
-
- org.jivesoftware.smackx.filetransfer.IncomingFileTransfer
-
public class IncomingFileTransfer extends FileTransfer
An incoming file transfer is created when theFileTransferManager.createIncomingFileTransfer(FileTransferRequest)
method is invoked. It is a file being sent to the local user from another user on the jabber network. There are two stages of the file transfer to be concerned with and they can be handled in different ways depending upon the method that is invoked on this class. The first way that a file is received is by calling thereceiveFile()
method. This method, negotiates the appropriate stream method and then returns the InputStream to read the file data from. The second way that a file can be received through this class is by invoking thereceiveFile(File)
method. This method returns immediately and takes as its parameter a file on the local file system where the file recieved from the transfer will be put.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jivesoftware.smackx.filetransfer.FileTransfer
FileTransfer.Error, FileTransfer.Status
-
-
Field Summary
-
Fields inherited from class org.jivesoftware.smackx.filetransfer.FileTransfer
amountWritten, negotiator, streamID
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
IncomingFileTransfer(FileTransferRequest request, FileTransferNegotiator transferNegotiator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cancels the file transfer.InputStream
receiveFile()
Negotiates the stream method to transfer the file over and then returns the negotiated stream.void
receiveFile(File file)
This method negotiates the stream and then transfer's the file over the negotiated stream.-
Methods inherited from class org.jivesoftware.smackx.filetransfer.FileTransfer
getAmountWritten, getError, getException, getFileName, getFilePath, getFileSize, getPeer, getProgress, getStatus, getStreamID, isDone, setError, setException, setFileInfo, setFileInfo, setStatus, updateStatus, writeToStream
-
-
-
-
Constructor Detail
-
IncomingFileTransfer
protected IncomingFileTransfer(FileTransferRequest request, FileTransferNegotiator transferNegotiator)
-
-
Method Detail
-
receiveFile
public InputStream receiveFile() throws SmackException, XMPPException.XMPPErrorException, InterruptedException
Negotiates the stream method to transfer the file over and then returns the negotiated stream.- Returns:
- The negotiated InputStream from which to read the data.
- Throws:
SmackException
- if Smack detected an exceptional situation.XMPPException.XMPPErrorException
- If there is an error in the negotiation process an exception is thrown.InterruptedException
- if the calling thread was interrupted.
-
receiveFile
public void receiveFile(File file) throws SmackException, IOException
This method negotiates the stream and then transfer's the file over the negotiated stream. The transferred file will be saved at the provided location. This method will return immediately, file transfer progress can be monitored through several methods:- Parameters:
file
- The location to save the file.- Throws:
SmackException
- when the file transfer failsIOException
- if an I/O error occurred.IllegalArgumentException
- This exception is thrown when the the provided file is either null, or cannot be written to.
-
cancel
public void cancel()
Description copied from class:FileTransfer
Cancels the file transfer.- Specified by:
cancel
in classFileTransfer
-
-