This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "ftp using java" Watch "ftp using java" New topic
Author

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:
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20289893.html#6944368
As for FTPing, I know about http://www.enterprisedt.com/downloads/ftp.html and http://www.geocities.com/SiliconValley/Code/9129/javabean/ftpbean/
and I also got a bit of code from this thread:
http://forum.java.sun.com/thread.jsp?thread=217004&forum=54&message=752443
However, that last thread mentioned a package called sun.net.ftp and I assume they meant java.net.ftp since they were talking about doing it in Java, but as far as I can tell, there's no ftp package in java.net, so I'm wondering what's up with that! Should I just be able to use all the classes in the java.net 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
Greenhorn

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 sun.net.ftp 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
Greenhorn

Joined: Jan 03, 2013
Posts: 1
Hi,

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: http://aspose.com/file-tools
 
subject: ftp using java
 
Similar Threads
uploading file to mainframe
RMI access denied client/server
downloading zip files from a site to local disk(urgent please)
Hi All
FileWriter to send a ftp a file