java中的The method canExecute() is undefined for the type File 为什么有这个错误啊
importjava.io.File;publicclassGetFileInfo{/***@paramargs*/publicstaticvoidmain(String...
import java.io.File;
public class GetFileInfo {
/**
* @param args
*/
public static void main(String[] args) {
String filePath="hello.txt";
File file=new File(filePath);
System.out.println("name:"+file.getName());
System.out.println("name:"+file.exists());
System.out.println("name:"+file.getPath());
System.out.println("name:"+file.getAbsolutePath());
System.out.println("name:"+file.canExecute());
System.out.println("name:"+file.canRead());
System.out.println("name:"+file.canWrite());
// TODO Auto-generated method stub
}
} 展开
public class GetFileInfo {
/**
* @param args
*/
public static void main(String[] args) {
String filePath="hello.txt";
File file=new File(filePath);
System.out.println("name:"+file.getName());
System.out.println("name:"+file.exists());
System.out.println("name:"+file.getPath());
System.out.println("name:"+file.getAbsolutePath());
System.out.println("name:"+file.canExecute());
System.out.println("name:"+file.canRead());
System.out.println("name:"+file.canWrite());
// TODO Auto-generated method stub
}
} 展开
2个回答
展开全部
是不是你的jdk版本不是1.6或以上的,
boolean java.io.File.canExecute()
Tests whether the application can execute the file denoted by this abstract pathname.
Returns:
true if and only if the abstract pathname exists and the application is allowed to execute the file
Throws:
SecurityException
- If a security manager exists and its java.lang.SecurityManager.checkExec(java.lang.String)
method denies execute access to the file
Since:
1.6
boolean java.io.File.canExecute()
Tests whether the application can execute the file denoted by this abstract pathname.
Returns:
true if and only if the abstract pathname exists and the application is allowed to execute the file
Throws:
SecurityException
- If a security manager exists and its java.lang.SecurityManager.checkExec(java.lang.String)
method denies execute access to the file
Since:
1.6
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询