code: public static String uploadFileToFTPServer(String hostName, Integer port, String userName,
                                                String password, String localFileFullName, String remotePath) {
          String result = null;
  
          FTPClient ftpClient = new FTPClient();
          String errorMessage = "Unable to upload file '%s' for FTP server '%s'.";
          InputStream inputStream = null;
  
          try {
              connectAndLoginOnFTPServer(ftpClient, hostName, port, userName, password);
              ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
              ftpClient.enterLocalPassiveMode();
  
              //String fullLocalPath = localPath + fileName;
              File localFile = new File(localFileFullName);
  
              //String fullRemotePath = remotePath + fileName;
              String remoteFile = remotePath + FilenameUtils.getName(localFileFullName);
              inputStream = new FileInputStream(localFile);
  
              boolean uploadFinished = ftpClient.storeFile(remoteFile, inputStream);
  
              if (uploadFinished) {
                  result = String.format("File '%s' successfully uploaded", localFileFullName);
              } else {
                  result = String.format("Failed upload '%s' file to FTP server. Got reply: %s",
                                                          localFileFullName, ftpClient.getReplyString());
              }
              } catch (IOException ex) {
                  throw new RuntimeException(String.format(errorMessage, remotePath, hostName), ex);
              } finally {
                  closeInputStream(inputStream);
                  disconnectAndLogoutFromFTPServer(ftpClient, hostName);
              }
          return result;
      }
docs: Upload a given file to FTP server.
  @param hostName the FTP server host name to connect
  @param port the port to connect
  @param userName the user name
  @param password the password
  @param localFileFullName the full name (inclusive path) of the local file.
  @param remotePath the path to the file on the FTP.
  @return reply string from FTP server after the command has been executed.
  @throws RuntimeException in case any exception has been thrown.