Home Java Javaftp FTPClient : List System Help
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

FTPClient : List System Help

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

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.
Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 11, 2012

Related Tutorials

Ask Questions?    Discuss: FTPClient : List System Help  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com