![](/img/trans.png)
[英]Getting last modified date of a file not the last created date in Java
[英]No file creation/modified date when a file created using HTTP PUT in java/Android
我正在為 android 開發一個應用程序,該應用程序使用 HTTP PUT 讀取/寫入無線設備。
有沒有辦法設置由 HTTP PUT 創建的文件的創建/修改日期和時間屬性,因為目前文件創建良好但沒有屬性(創建日期時間,修改日期時間。
如果您需要一些代碼片段,請告訴我。(不確定有什么幫助)
這可能是設備的后備,即設備負責將這些屬性添加到文件中嗎?
我試過在網上搜索,但這個問題很難用 1 行/幾句話來解釋:)
提前致謝。
編輯:為了澄清,我試圖寫的文件已經存在,所以 HTTP PUT 只是覆蓋它。(簡單的文本文件)。 所以我只是傳遞一個 BYTEARRAY 實體來寫入這個文件。 但不知何故,在這個過程中,文件屬性正在丟失。
編輯:以下是 uploadFile 代碼片段。 私人無效上傳文件(字符串數據){
try{
HttpClient http = new DefaultHttpClient(); //declare and initialize the HTTP client.
//Using HTTP PUT, upload the data to the Settings file
HttpPut putmethod = new HttpPut("http://airstash.net/files/SETTINGS.TXT");
putmethod.setEntity(new ByteArrayEntity(data.getBytes("iso-8859-1")));
putmethod.setHeader("Content_Type", "Text/Plain");
HttpResponse response = http.execute(putmethod); //Execute the PUT request and receive response.
if(response!= null)
{
//Show the response code (for testing only)
String responsecode = Integer.toString(response.getStatusLine().getStatusCode());
Toast.makeText(getApplicationContext(), responsecode, Toast.LENGTH_LONG).show();
}
}
catch(Exception e){
e.printStackTrace();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.