FTPClient : List System Help

This section lists the help information provided by FTP server class in java.

FTPClient : List System Help

FTPClient : List System Help

This section lists the help information provided by FTP server class in java.

List System Help :

String listHelp() :This method retrieves the list of help information provided by the server and it returns the content in String. If there is no help information from the server then it will return null.

public String listHelp(String command) : Retrieves the help info from the ftp server for the specified command. Its return value in String.It returns null if there is no information.

command represents what you ask for help.

These methods throw FTPConnectionClosedException if server is closed before completion of operation and IOException, if there is any I/O error.

Example :

This example print the list of all the help info provided by the ftp server. We can list it by using FTPClient class method listHelp().

Here is complete code -

import java.io.IOException;

import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPConnectionClosedException;

class FtpListHelp{
	public static void main(String[] args) throws IOException {
	FTPClient client = new FTPClient();
	boolean result;
	try {
		// Connect to the localhost
		client.connect("localhost");
		
		// login to ftp server
		result = client.login("admin", "admin");

		if (result == true) {
			System.out.println("User successfully logged in.");
		} else {
			System.out.println("Login failed!");
			return;
		}
		
		//Get List of system help
		
		System.out.println("System Help Information.... ");
		System.out.println(client.listHelp());

	} catch (FTPConnectionClosedException e) {
		System.out.println(e);
	} finally {
		try {
			client.disconnect();
		} catch (FTPConnectionClosedException e) {
			System.out.println(e);
		}
	}
}
}

Output :

User successfully logged in.
System Help Information.... 
200- Support the following ftp commands: 
200- LIST,PASV,PORT,RETR,CWD,XCWD,CDUP,XCUP
200- PWD,XPWD,TYPE,NOOP,STOR,DELE,REST,ABOR
200- USER,PASS,MODE,SIZE,APPE,MKD,XMKD,RMD,XRMD
200- RNFR,RNTO,QUIT,STRU,MDTM,HELP,NLST,STOU,SITE
200 200 Help OK.