Question: 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?

Answer: 
```
FTPClient f = new FTPClient();
f.connect("localhost");
f.login(username, password);
FTPFile[] files = listFiles(directory);   

```

**Also See** 

* [Article from JavaWorld](http://www.javaworld.com/javaworld/jw-04-2003/jw-0404-ftp.html)
* [JavaDoc](http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html)
The [`FTPClient.connect()`](http://commons.apache.org/net/api/org/apache/commons/net/SocketClient.html#connect%28java.lang.String%29) method takes the *name* of a server, not a URL. Try:

```
ftp.connect("localhost");

```

Also, you may need to put `alfresco` somewhere else. If it's part of the file path,

```
String file = "alfresco/KPUB//Admin//TMM//Pickup//TMM_TO_ARTESIA_06152010220246.xml";

```