File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes ftp using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "ftp using java" Watch "ftp using java" New topic

ftp using java

Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
I tried searching for relevant posts so as not to waste people's time on here, but the search only turned up stuff from as late as 2001, and it didn't exactly clarify my questions. How does one do simple FTP work in Java? I just need to download a zip file from a server and check that it's up-to-date by parsing the info given on the HTML page and making sure it matches the info on the file I've downloaded. I think I can do that, plus, I know how to parse stuff, and also know about JTidy, as well as the handy code on this page:
As for FTPing, I know about and
and I also got a bit of code from this thread:
However, that last thread mentioned a package called and I assume they meant since they were talking about doing it in Java, but as far as I can tell, there's no ftp package in, so I'm wondering what's up with that! Should I just be able to use all the classes in the package to do this bit of simple FTPing that I want to do, or do I need to know something else, or should I just use one of the free tools from the other two URLs that I mentioned? I definitely don't want to reinvent the wheel, but if the code is simple enough I would just as soon do it on my own (ftp to a site, get a file, do some checking on it, etc). I'm preferring to do this in Java and then schedule it in a batch file a dozen times per day just b/c I'm used to all the exception/error handling I get in Java.
Jerry Kreps

Joined: Jun 16, 2003
Posts: 12
Hi, Stephen --
I was in your shoes not too long ago, looking for a way to do FTP operations in Java. I do not recommend the package. It is not intended for public use and is not documented very well. There are several different ftp tools in Java, but the one that I use is the open source Apache Commons Net package that is really slick. You can download it at
this location.
Here is a procedure that I wrote that uses this tool to perform ftp file transfers of files in a specified source directory and to rename the source files afterward. As you can see, it is pretty simple. However, in getting it to work I did find that one of the object methods in the package had a bug for which I had to find a work-around. For further info on this, see my thread in this forum.

Hope this helps
[ August 04, 2003: Message edited by: Jerry Kreps ]
[ August 04, 2003: Message edited by: Jerry Kreps ]
[ August 04, 2003: Message edited by: Jerry Kreps ]
Pallavi Garga

Joined: Jan 03, 2013
Posts: 1

But the above code is giving exception at ftpClient.listName(); Line 46
Exception is Connection closed without indication.

Please Help
I agree. Here's the link:
subject: ftp using java
It's not a secret anymore!