code: public static boolean deleteDirectoryFromFTPServer(String hostName, Integer port, String userName, String password, String remotePath) {
          boolean deleted = false;
  
          FTPClient ftpClient = new FTPClient();
          String errorMessage = "Could not delete the directory '%s' from FTP server '%s'. Cause: %s";
  
          try {
              connectAndLoginOnFTPServer(ftpClient, hostName, port, userName, password);
              deleted = ftpClient.removeDirectory(remotePath);
          } catch (IOException ex) {
              throw new RuntimeException(String.format(errorMessage, remotePath, hostName), ex);
          } finally {
              disconnectAndLogoutFromFTPServer(ftpClient, hostName);
          }
          return deleted;
      }
docs: Delete given directory from FTP server (directory must be empty).
  @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 remotePath the path to the directory on the FTP to be removed
  @return true if file has been removed  and false otherwise.
  @throws RuntimeException in case any exception has been thrown.