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:

  • connecting to ftp using sun.net.ftp.ftpclient
  • sun.net.ftp.FtpClient binary
  • establish_ftp_connection in perl
  • sun.net.ftp.FtpClient+Connection+reset
  • sun.net.ftp.
  • sun.net.ftp.FtpClient java timeout
  • how to establish ftp connection using java
  • java7 ftpclient connect example
  • sun.net.ftp.ftpclient example
  • java datatype ftpclient

No comments yet.

Leave a Comment