aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Remove files from folder in sftp 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 "Remove files from folder in sftp" Watch "Remove files from folder in sftp" New topic
Author

Remove files from folder in sftp

Ganeshkumar cheekati
Ranch Hand

Joined: Oct 13, 2008
Posts: 362
Hi,

i need to remove all files from one folder in sftp from java? please let me know which api is best to do this task?


Thanks in advance
Ganesh Kumar CH


SCJP5 and SCWCD1.5
Think Twice Act Wise...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

I don't know how many SFTP APIs you were considering in your review, but removing a file is a very simple operation and any API which supports that operation would be suitable. Looking for the "best" at this task isn't a good use of anybody's time.
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 960
    
  10

There is no single command in version 3 of the SFTP protocol (which is what openssh conforms to) for removing the content of a directory so that any Java library that does this in one command will internally need to first list all the files in the directory and then iterate over the list removing each one in turn. This should take no more than half a dozen lines of code for you to write yourself and unless the Java library does the deletes asynchronously (which is what the protocol allows) your code will be as fast as any other.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Remove files from folder in sftp
 
Similar Threads
error in rm method of J2SSH
can not read file
Remove ^M character in text file
Log between two Time
package apache.commons not exists