Created
April 19, 2013 10:19
-
-
Save mgdelacroix/5419444 to your computer and use it in GitHub Desktop.
FTPClient test. Download All Things!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group='commons-net', module='commons-net', version='2.0') | |
import org.apache.commons.net.ftp.FTPClient | |
import org.apache.commons.net.ftp.FTPFile | |
new FTPClient().with { | |
connect '61.135.158.199' | |
println replyString | |
enterLocalPassiveMode() | |
login('anonymous', '') | |
println replyString | |
changeWorkingDirectory('pub') | |
changeWorkingDirectory('books') | |
listFiles().each { file -> | |
if (file.type == FTPFile.FILE_TYPE) { | |
println "FILE: ${file.name}" | |
def incomingFile = new File(file.name) | |
incomingFile.withOutputStream { ostream -> | |
retrieveFile file.name, ostream | |
} | |
} | |
} | |
println "Me voy" | |
disconnect() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment