public static String copyZipFiles() {
FTPClient client = new FTPClient();
String msg="";
String ip="";
String userName="";
String password="";
try {
client.connect(ip);
client.login(userName, password);
client.setFileType(FTP. BINARY_FILE_TYPE);
FTPFile[] dir =client.listDirectories( "foldername");
for (FTPFile ftpFile : dir) {
FTPFile[] files = client.listFiles("foldername"+ ftpFile.getName());
File createFile=new File("local path to create directory");
createFile.mkdirs();
for (FTPFile xmlfiles : files) {
File writerfile=new File("name and location of the file going to write the file for temp to process");
FileOutputStream output;
output = new FileOutputStream(writerfile, false);
client.connect(ip);
client.login(userName, password);
client.retrieveFile( "direcory or subdirectory path of ftp server "+"/"+ xmlfiles.getName(), output);
//close output stream
output.close();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return msg;
}
Comments
Post a Comment