code: public Path upload(final File localFile) throws IOException {
  
      if (!localFile.exists()) {
        throw new FileNotFoundException(localFile.getAbsolutePath());
      }
  
      final Path source = new Path(localFile.getAbsolutePath());
      final Path destination = new Path(this.path, localFile.getName());
  
      try {
        this.fileSystem.copyFromLocalFile(source, destination);
      } catch (final IOException ex) {
        LOG.log(Level.SEVERE, "Unable to upload " + source + " to " + destination, ex);
        throw ex;
      }
  
      LOG.log(Level.FINE, "Uploaded {0} to {1}", new Object[] {source, destination});
  
      return destination;
    }
docs: Upload given file to the DFS.
  @param localFile File on local FS to upload to the (remote) DFS.
  @return the Path representing the file on the DFS.
  @throws IOException if unable to upload the file or local file cannot be read.