live-server --port=8000
我使用上面的String server = "www.test.com";
int port = 21;
String username = "test";
String password = "test";
FTPClient ftpclient = new FTPClient();
try {
ftpclient.connect(server,port);
ftpclient.login(username, password);
ftpclient.enterLocalPassiveMode();
ftpclient.setFileType(FTP.BINARY_FILE_TYPE);
String remoteFile = "/home/test/workspace/9001_20150918165942_00085.xml";
File downloadfile = new File("C:/Users/Workspace/9001_20150918165942_00085.xml");
OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(downloadfile));
boolean success = ftpclient.retrieveFile(remoteFile, outputStream1);
outputStream1.close();
if (success) {
System.out.println("File has been downloaded successfully.");
}
} catch (IOException ex) {
System.out.println("Error: " + ex.getMessage());
ex.printStackTrace();
}
finally {
try {
if (ftpclient.isConnected()) {
ftpclient.logout();
ftpclient.disconnect();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
将文件从Linux机器下载到Windows机器。对于目标文件,它工作正常。
但我正在尝试使用正则表达式来实现相同的目标。例如,FTPClient
将被下载到/home/test/workspace/*.xml
。