로컬 폴더 파일의 lastmodifeddate를 FTP 파일의 lastmodifieddate로 설정하려고했습니다. 그러나 반환 값에서 false를 반환하고 date도 올바르게 설정되지 않습니다. 여기 Java에서 lastmodifieddate 설정 오류가 발생했습니다.
는public static void getModifiedDateAndTimeFromFTPFile(String FTPHost, String FTPUserName, String FTPPassword, String FTPRemoteDirectory, String localFilePath, String fileName) {
try{
//get Local File
File fileLocal = new File(localFilePath + fileName);
//Connect to FTP and get the lastmodified time of File.
FTPClient client = new FTPClient();
client.connect(FTPHost);
client.login(FTPUserName, FTPPassword);
client.changeWorkingDirectory(FTPRemoteDirectory);
FTPFile ftpFile = client.listFiles(fileName)[0];
//Get last_modified date of FTP file.
Date ftpFileDate = ftpFile.getTimestamp().getTime();
//Now set date to the Local File.
boolean boolSetTime = fileLocal.setLastModified(ftpFileDate.getTime());
System.out.println(" Was last modified time set successfully ? : " + boolSetTime);
} catch (Exception ex) {
System.out.println("Error : " + ex.toString());
}
}
이 사람이 내 실수를 지적으로 도와 줄 수, 기능인가?
감사
ftpFileDate.getTime()을 에코 해 보셨습니까? 또한 해당 파일에 대한 사용 권한이 있습니까? –
예 파일에 액세스 할 수있는 권한이 있습니다. 파일을 다운로드 할 수도 있습니다. –
또한 ftpFileDate.getTime()을 인쇄하려고 시도했으며 정확한 lastmodifed 날짜를 반환합니다. –