Home Java Javaftp FTP Server: Get Buffer size



FTP Server: Get Buffer size
Posted on: December 10, 2012 at 12:00 AM
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

Related Tags for FTP Server: Get Buffer size:


More Tutorials from this section

Ask Questions?    Discuss: FTP Server: Get Buffer size  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.