I want to get the file properties in assets folder on android,But it is unlike general operation use some kinds of methods to get,anybody can help me to get the file properties such as modified date. My assets file has a "ok.txt",please do me a help?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If I understand you correctly, I think this blog post will answer your question, with code showing example of using InputStream:
http://myossdevblog.blogspot.com/2010/02/reading-properties-files-on-android.html
回答2:
You can get last modified date with lastModified()
.
File file = new File(<file path>);
long lastModified = file.lastModified();
But lastModified()
returns unix time. You can convert it with format.
Date date = new Date(lastModified);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SS");
String formattedDate = sdf.format(date);
回答3:
Take a look at the documentation of File class, there are lots of methods to get any kind of information about a file.