FTP Server: Get Buffer size

Ads
 

FTP Server: Get Buffer size

This tutorial helps you to get the current internal buffer size on FTP server using java.

This tutorial helps you to get the current internal buffer size on FTP server using java.

FTP Server: Get Buffer size

This tutorial helps you to get the current internal buffer size on FTP server using java.

Get Buffer Size :

You can find out the current internal buffer size for your data socket by using the FTPClient class method.

int getBufferSize() : This method returns int value. It fetches the present internal buffer size for your data sockets.

Example :

Here is an example to print the internal buffer size for our data socket.For that we are calling method client.getBufferSize().

import java.io.IOException;

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

class FtpGetBufferSize {
	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 buffer size
			System.out.println("Current Buffer size : "
					+ client.getBufferSize());

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

Output :

User successfully logged in.
Current Buffer size : 1024

Ads

Ads