java操作FTP文件
使用开源项目:ftp4jhttp://www.sauronsoftware.it/projects/ftp4j/
示例:
import java.io.File;
import it.sauronsoftware.ftp4j.FTPClient;
import it.sauronsoftware.ftp4j.FTPFile;
public class javaFTP {
private static final String Local_Folder="D://examples//";
public static void main(String[] args) {
try {
FTPClient client = new FTPClient();
client.connect("192.168.0.150", 21);
client.login("admin", "123456");
FTPFile[] list = client.list("text.xls");
FTPFile file = list;
File localfile=new File(Local_Folder+list.getName());
client.download(file.getName(), localfile);
client.rename(file.getName(), "history/" + file.getName());
client.disconnect(true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
页:
[1]