Hi Everyone,
I'm trying to test if the input file exist exist in FTP server or not.If The file exist I want to display File exist.If not then display File not found messages.
see the below code once
import org.apache.commons.net.ftp.FTPClient
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPFile;
import java.text.SimpleDateFormat;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat
import groovy.io.FileType
start()
def start(){
def ftpClient = new FTPClient()
ftpClient.connect(server)
ftpClient.login(user,pass)
ftpClient.enterLocalPassiveMode()
FTPFile[] f= ftpClient.listFiles("/Autoplus.txt");
for(FTPFile ff : f){
if(ff.exists()){
return "File existed"
}
else{
return "File not found!"
}
}
}
The above doesn't executed please if any errors in that,please suggest your inputs
Thanks