public static synchronized void getFtpTime(){
new Thread(() -> {
FTPClient ftpClient = new FTPClient();
try {
ftpClient.connect(ip,port);
ftpClient.login(user,password);
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
//创建或追加文件time.txt
OutputStream outputStream = ftpClient.appendFileStream("time.txt");
outputStream.write("1".getBytes());
outputStream.flush();
outputStream.close();
ftpClient.completePendingCommand();//OutputStream完成
for(FTPFile file : ftpClient.listFiles()){
if(file.getName().equals("time.txt")) {
//获取文件修改时间
long time = file.getTimestamp().getTimeInMillis();
Log.d("", "getFtpTime: "+time);
}
}
ftpClient.deleteFile("time.txt");
ftpClient.logout();
} catch (IOException e) {
Log.d("'", "getFtpTime: error "+e.toString());
}
}).start();
}
04-26
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交