code: public void receiveFile(final File file) throws SmackException, IOException {
          if (file == null) {
              throw new IllegalArgumentException("File cannot be null");
          }
          if (!file.exists()) {
                   file.createNewFile();
              }
          if (!file.canWrite()) {
                  throw new IllegalArgumentException("Cannot write to provided file");
          }
  
          Thread transferThread = new Thread(new Runnable() {
              @Override
              public void run() {
                  try {
                      inputStream = negotiateStream();
                  }
                  catch (Exception e) {
                      setStatus(FileTransfer.Status.error);
                      setException(e);
                      return;
                  }
  
                  OutputStream outputStream = null;
                  try {
                      outputStream = new FileOutputStream(file);
                      setStatus(Status.in_progress);
                      writeToStream(inputStream, outputStream);
                  }
                  catch (FileNotFoundException e) {
                      setStatus(Status.error);
                      setError(Error.bad_file);
                      setException(e);
                  }
                  catch (IOException e) {
                      setStatus(Status.error);
                      setError(Error.stream);
                      setException(e);
                  }
  
  
                  if (getStatus().equals(Status.in_progress)) {
                      setStatus(Status.complete);
                  }
                  CloseableUtil.maybeClose(inputStream, LOGGER);
                  CloseableUtil.maybeClose(outputStream, LOGGER);
              }
          }, "File Transfer " + streamID);
          transferThread.start();
      }
docs: 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:
  
  <UL>
  <LI>{@link FileTransfer#getStatus()}</LI>
  <LI>{@link FileTransfer#getProgress()}</LI>
  <LI>{@link FileTransfer#isDone()}</LI>
  </UL>
  
  @param file The location to save the file.
  @throws SmackException when the file transfer fails
  @throws IOException
  @throws IllegalArgumentException This exception is thrown when the the provided file is
  either null, or cannot be written to.