FTPClient : Get System Type

This section explain how to get system type by using method of FTPClient class in java.

FTPClient : Get System Type

FTPClient : Get System Type

This section explain how to get system type by using method of FTPClient class in java.

Get System Type :

String getSystemType() : Return type of this method is String. This method always holds the system type which is acquired from the ftp server. When you call this metthod it issue a SYST command to the FTP server and FTPClient put this value in cache till system is connected to the ftp server.

It throws FTPConnectionClosedException and IOException.

Example :

In this example we are using getSystemType() method of FTPClient class to get the system type of FTP server.

import java.io.IOException;

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

class FtpGetSystemType{
	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 System Type
			
			System.out.println("System type : "+client.getSystemType());

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

Output :

User successfully logged in.
System type : UNIX Type: L8