aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes delete using ftp protocol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "delete using ftp protocol" Watch "delete using ftp protocol" New topic
Author

delete using ftp protocol

Stephanie Smith
Greenhorn

Joined: Jun 28, 2001
Posts: 22
I am trying to delete a file using the FTP protocol. I was looking at the URL class but there doesn't appear to be a way to do this....do I have to write an ftp client in order to perform this deletion using ftp?
thanks steph
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
I don't think there is a way to delete a file with a simple URL.
You have to open a FTP control connection, then USER, PASS, CD, and DELETE. You won't do this with a URLConnection object. You will have to use a Socket object. Or find an implementation of an FTP Client in Java.
Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
Originally posted by Michael Zalewski:
I don't think there is a way to delete a file with a simple URL.
You will have to use a Socket object.

Does URLConnection class is only helpful for making http url connections ? . for any other protocol why is not advisable to make use of URLConnection class.
P.S : Sorry for deviating from the original topic.

Thanks in advance


Raghav.
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
Originally posted by raghav mathur:

Does URLConnection class is only helpful for making http url connections ? . for any other protocol why is not advisable to make use of URLConnection class.
P.S : Sorry for deviating from the original topic.

Thanks in advance

URLConnection is used to make a connection to any URL. It can even be ftp://server/.../file. But the 'ftp://' protocol only lets you receive the file. As far as I know, you cannot even use 'ftp://' to send a file to the server.
The problem is that the URL protocol 'ftp://' is only a subset of the FTP protocol. To get the full function of FTP, you will have to either find another FTP client for java, or write your own socket driver.
Here's the fun part. To speak FTP, you actually need *two* sockets, one for control and one for data. You send the FTP commands such as DELETE or LIST to the control socket, and receive a response such as "200 OK". You send and receive the files to be uploaded or downloaded to the data socket.
I am certain that there must be a good open source FTP client in 100% Java out there. I don't know where though. Anyone?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
There's an LGPL one here that looks nice and simple. Haven't tried it though. If you also want NNTP, SMTP, POP3, finger, the works, then try NetComponents which comes with a more restrictive license.
- Peter
[ October 31, 2002: Message edited by: Peter den Haan ]
Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
Thanks for the links Peter . I think they are going to be very helpful in my proxy server implementation .
[ November 01, 2002: Message edited by: raghav mathur ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: delete using ftp protocol