Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Javaftp FTP Server: Get Buffer size

Related Tutorials


 
 

Share on Google+Share on Google+

FTP Server: Get Buffer size

Advertisement
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
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 10, 2012

Related Tutorials

Discuss: FTP Server: Get Buffer size  

Post your Comment


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