|
示例代码:
public class Test {
public static void main(String[] args) {
File file = new File("src\\weizhang\\Test.java");
if (file.isFile()) {
String str1=file.canExecute()?"可执行文件":"不可执行文件";
System.out.println(str1);
String str2=file.canRead()?"可读文件":"不可读文件";
System.out.println(str2);
String str3=file.canWrite()?"可写文件":"不可写文件";
System.out.println(str3);
Date date=new Date(file.lastModified());
**DateFormat sdf=new **DateFormat("yyyy-MM-dd");
String str4=sdf.format(date);
System.out.println(str4);
}
}
}
|