51,409
社区成员
发帖
与我相关
我的任务
分享
boolean canExecute()
测试应用程序是否可以执行此抽象路径名表示的文件。
boolean canRead()
测试应用程序是否可以读取此抽象路径名表示的文件。
boolean canWrite()
测试应用程序是否可以修改此抽象路径名表示的文件。
boolean isFile()
测试此抽象路径名表示的文件是否是一个标准文件。
boolean isHidden()
测试此抽象路径名指定的文件是否是一个隐藏文件。
lastModified()
返回此抽象路径名表示的文件最后一次被修改的时间。
try {
File file = new File("a.txt");
if (file.exists()) {
FileInputStream is=new FileInputStream(file);
InputStreamReader isr=new InputStreamReader(is);
BufferedReader reader=new BufferedReader(isr);
String str=null;
while ((str=reader.readLine())!=null) {
//标题、主题、作者、关键字、备注、修改时间
if (str.startsWith("标题")) {
String title=str.split(":")[1];
}
if (str.startsWith("主题")) {
String theme=str.split(":")[1];
}
if (str.startsWith("作者")) {
String author=str.split(":")[1];
}
if (str.startsWith("关键字")) {
String word=str.split(":")[1];
}
if (str.startsWith("备注")) {
String remark=str.split(":")[1];
}
if (str.startsWith("修改时间")) {
String time=str.split(":")[1];
}
}
}
} catch (Exception e) {
e.printStackTrace();
}