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

Home Java Javaftp FTP Server : Connect and Login

Related Tutorials


Share on Google+Share on Google+

FTP Server : Connect and Login

In this tutorial we will discuss how to connect and login in FTP server with java programming.

FTP Server : Connect and Login

In this tutorial we will discuss how to connect and login in FTP server with java programming.

FTP Server :

By using FTP Server you can transfer files from one computer to another computer through network and internet. For FTP server, it is required to authenticate user by inputting the user name and password.

Connect and Login : 

For connecting to the ftp server we need some APIs which is provided by the class FTPClient(
For connecting to the server FTPClient provides connect(String hostname) method. For local machine hostname is "localhost"


For login we can use login() method. This method returns boolean value. If you logged in then it will return true else it will return false.


Example :  In this example we are connecting to the ftp server. hostname is "localhost".



class FtpConnect {
	public static void main(String[] args) throws IOException {
		FTPClient client = new FTPClient();
		try {
			boolean login = client.login("deepak", "deepak");

			if (login == true) {
				System.out.println("Successfully logged in!");
			} else {
				System.out.println("Login Fail!");
		} catch (FTPConnectionClosedException e) {
		} finally {
			try {
			} catch (FTPConnectionClosedException e) {

Output :

Successfully logged in!

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 4, 2012

Related Tutorials

Discuss: FTP Server : Connect and Login  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
May 27, 2013

How do you create localhost? and i code in neatbean and what do i need to connect this localhost??