错误信息:
An error occurred at line: 2 in the jsp file: /test.jsp
Generated servlet error:
C:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\test_jsp.java:46: non-static method exec(java.lang.String) cannot be referenced from a static context
Runtime.exec("attrib -r " + "aa.txt");
^
1 error
仔细看看API中的File类,里面有相应的方法。
canRead
public boolean canRead()
Tests whether the application can read the file denoted by this abstract pathname.
Returns:
true if and only if the file specified by this abstract pathname exists and can be read by the application; false otherwise
public boolean canWrite()
Tests whether the application can modify to the file denoted by this abstract pathname.
Returns:
true if and only if the file system actually contains a file denoted by this abstract pathname and the application is allowed to write to the file; false otherwise.
setReadOnly
public boolean setReadOnly()
Marks the file or directory named by this abstract pathname so that only read operations are allowed. After invoking this method the file or directory is guaranteed not to change until it is either deleted or marked to allow write access. Whether or not a read-only file or directory may be deleted depends upon the underlying system.
Returns:
true if and only if the operation succeeded; false otherwise