How to give FTP address in java?

Posted by i2ijeya on Stack Overflow See other posts from Stack Overflow or by i2ijeya
Published on 2010-12-30T12:19:04Z Indexed on 2010/12/30 13:54 UTC
Read the original article Hit count: 200

Filed under:
|
|
|

I have written the code which downloads the file from FTP server. Since I have my FTP server locally and I want to access like "ftp://localhost/alfresco". It was alfresco's FTP.

I have the following Code

public class FtpTransfer {
public static final void main(String[] args)
{
    FTPClient ftp = new FTPClient();
    FileOutputStream br = null;
    try
    {
        ftp.connect("ftp://localhost/alfresco");
        ftp.login("admin", "admin");
        String file = "KPUB//Admin//TMM//Pickup//TMM_TO_ARTESIA_06152010220246.xml";

        br = new FileOutputStream("file");
        ftp.retrieveFile("/"+file, br);
        System.out.println("Downloaded...");
    }
    catch(IOException exception) {
        System.out.println("Error : "+exception);
    }
}
}

The following exception occurs.

Error : java.net.UnknownHostException: ftp://localhost/alfresco

Please let me know how should I give the FTP Host Address?

© Stack Overflow or respective owner

Related posts about java

Related posts about server