Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to establish ftp connection using sun.net.ftp.FtpClient

Java: How to establish ftp connection using sun.net.ftp.FtpClient
{filelink=9030}

import java.io.IOException;
import sun.net.ftp.FtpClient;
public class FTExample
 {
	private static  FtpClient ftp_clt;
  public static void main (String[] argv)throws Exception
  	{ 
    try
    {
      // Le serveur FTP
      String ftp_serv = "ftp.tubedir.com";
      // username
      String username = "admin";
      // password
      String password = "123456";
      // Working directory
      String rep = "htdoc/site2";
      ftp_clt = FtpClient.create(ftp_serv);
      ftp_clt.login(username, password.toCharArray());
      System.out.println("User : " + username + " connected");
      System.out.println(ftp_clt.getWelcomeMsg());
      ftp_clt.changeDirectory(rep);
      System.out.println("---->: " + rep);
      ftp_clt.setBinaryType();
      System.out.println("Connection successful.");
    }
    catch (Exception ex)
    {
      System.out.println("Errot: " + ex.getMessage());
    }
    finally
    {
    	ftp_clt.close();
    }
  }
}

Users who found this page were searching for:

  • sun.net.ftp.ftpclient example
  • java datatype ftpclient
  • how to establish ftp connection using java
  • java7 ftpclient connect example
  • how to download a directory from ftp server using sun.net java
  • sun ftpclient java net sample
  • connect sun.net.ftp.ftpclient example
  • sun.net.ftp.ftpclient exception
  • sun.net.ftp.ftpclient list
  • how to connect FTP server with user

No comments yet.

Leave a Comment