久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 Apache FTPClient 檢索文件時(shí)如何保留修改日期

How to preserve date modified when retrieving file using Apache FTPClient?(使用 Apache FTPClient 檢索文件時(shí)如何保留修改日期?)
本文介紹了使用 Apache FTPClient 檢索文件時(shí)如何保留修改日期?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在使用 org.apache.commons.net.ftp.FTPClient 從 ftp 服務(wù)器檢索文件.當(dāng)文件保存在我的機(jī)器上時(shí),我保留文件上最后修改的時(shí)間戳是至關(guān)重要的.有人對如何解決這個(gè)問題有建議嗎?

I am using org.apache.commons.net.ftp.FTPClient for retrieving files from a ftp server. It is crucial that I preserve the last modified timestamp on the file when its saved on my machine. Do anyone have a suggestion for how to solve this?

推薦答案

我是這樣解決的:

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;
}

我希望 Apache 團(tuán)隊(duì)能夠?qū)崿F(xiàn)此功能.

I wish the Apache-team would implement this feature.

你可以這樣使用它:

List<FTPFile> ftpFiles = Arrays.asList(client.listFiles());
for(FTPFile file : ftpFiles) {
    retrieveFile("/tmp", file.getName(), file.getTimestamp().getTime());
}

這篇關(guān)于使用 Apache FTPClient 檢索文件時(shí)如何保留修改日期?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環(huán)繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動(dòng)生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數(shù)據(jù)庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 国外成人免费视频 | 免费黄色av网站 | 久久国产成人 | 欧美久久久电影 | 国产特一级黄色片 | 久久精品97| 伊人精品一区二区三区 | 欧美日韩国产传媒 | 九九在线视频 | 精品国产一区二区三区久久久蜜月 | 精品国产一区二区三区日日嗨 | 国产一区二区三区四区三区四 | 亚洲色图婷婷 | 欧美一区二区三区 | av在线影院 | 欧美精品久久 | 国产一区二区三区在线 | 视频一区二区在线观看 | 国产a区| 精品视频一区二区三区四区 | 中文字幕高清 | 美女福利视频网站 | 久久久久久免费精品一区二区三区 | 天堂综合网久久 | 黄色香蕉视频在线观看 | 午夜免费在线电影 | 久久天堂网 | 国产精品一区二区不卡 | 欧美a区| 精品一区二区三区电影 | 最新中文字幕在线 | 国产精品高潮呻吟久久 | 在线观看视频亚洲 | 国产女人精品视频 | 亚洲国产成人在线观看 | 一区二区三区四区五区在线视频 | 日韩视频一区在线观看 | 欧区一欧区二欧区三免费 | 黄在线免费观看 | 亚洲精彩视频 | 亚洲草草视频 |