【发布时间】:2014-12-31 21:39:55
【问题描述】:
我的目标很简单:我的资产文件夹中有一个 zip 文件,并希望获得它的最后修改日期。
我可以通过 Assetmanager 访问该文件并从中创建一个文件,但修改日期是该文件被写入的时刻
AssetManager manager;
File checkFile = new File(source + "/" + "test.zip");
try
{
InputStream stream = manager.open(fileToCheck);
int size = stream.available();
byte[] buffer = new byte[size];
stream.read(buffer);
stream.close();
FileOutputStream fos = new FileOutputStream(checkFile);
fos.write(buffer);
fos.close();
}
catch(IOException ioExc)
{
//stuff
}
long lastMod = checkFile.lastModified();
Date lastMod = new Date(lastMod ); //This is returning the current time,
//NOT the modified date of the file
谁能想到我可以访问资产文件夹中文件的实际最后修改日期的方法?任何帮助将不胜感激!
【问题讨论】:
标签: android android-file android-assets