code: public static Integer getFileSizeOnFTPServer(String hostName, Integer port,
              String userName, String password, String filePath) {
          Integer result = null;
  
          // get file size
          String replyString = executeCommandOnFTPServer(hostName, port, userName, password, "SIZE", filePath);
  
          if (replyString == null || !replyString.contains(" ")) {
              throw new  RuntimeException(String.format(
                      "Unable to get size of the %s file. Got [%s] reply from FTP server.", filePath, replyString));
          } else {
              result = Integer.valueOf(replyString.split(" ")[1].replaceAll("[\r\n]", ""));
          }
          return result;
      }
docs: Get size of the FTP file.
  @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 filePath file to get size for.
  @return file's size if found.
  @throws RuntimeException in case any exception has been thrown.