ftp 서버에서 파일을 가져 오는 데 org.apache.commons.net.ftp.FTPClient
을 사용하고 있습니다. 내 컴퓨터에 파일을 저장할 때 마지막으로 수정 한 타임 스탬프를 보존하는 것이 중요합니다. 누구든지 이것을 해결하는 방법에 대한 제안을 가지고 있습니까?Apache FTPClient를 사용하여 fil를 검색 할 때 수정 된 날짜를 보존하는 방법은 무엇입니까?
3
A
답변
2
파일을 다운로드 한 후 타임 스탬프를 수정할 수 있습니다.
타임 스탬프는 LIST 명령 또는 (비표준) MDTM 명령을 통해 검색 할 수 있습니다. 그 :
당신은 타임 스탬프를 수정하는 방법을 여기에서 볼 수있는 것은 http://www.mkyong.com/java/how-to-change-the-file-last-modified-date-in-java/
1
이것은 내가 그것을 해결하는 방법입니다
public boolean retrieveFile(String path, String filename, long lastModified) throws IOException {
File localFile = new File(path + "/" + filename);
OutputStream outputStream = new FileOutputStream(localFile);
boolean success = client.retrieveFile(filename, outputStream);
outputStream.close();
localFile.setLastModified(lastModified);
return success;
}
내가 아파치 팀이 기능을 구현하는 것이 좋겠다.
이
당신이 그것을 사용하는 방법입니다 :List<FTPFile> ftpFiles = Arrays.asList(client.listFiles());
for(FTPFile file : ftpFiles) {
retrieveFile("/tmp", file.getName(), file.getTimestamp().getTime());
}