• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

delete using ftp protocol  RSS feed

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Michael Zalewski
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!