| 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: 16482
|
|
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: 361
|
|
|
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.
|
 |
 |
|
|
subject: Remove files from folder in sftp
|
|
|