File object, which can be applied to read&write local files.
Note: it can only read&write files which are under the root path of current website.
| String |
name Returns the name of the file or directory denoted by this abstract pathname. |
| String |
path Return this abstract pathname. |
| String |
absolutepath Returns the absolute pathname string of this abstract pathname. |
| NpsFile |
new(String filename) Return to NpsFile object whose filename is designated filename will be automatically mapped to the root path of currently in-use website. For example: the root path of current website is “c:\web”, then in case of the following situation: 1.filename=c:\web\logs\mylog.txt 2.filename=c:\logs\mylog.txt 3.filename=/logs/mylog.txt the final result will point to “c:\web\logs\mylog.txt” files. |
| boolean |
IsFile() Whether it is file or not. If it is file, it will return to True, otherwise, it will return to false. |
| boolean |
IsDirectory() Whether it is directory or not. If it is directory, it will return to True, otherwise, it will return to false. |
| boolean |
Exists() Tests whether the file or directory denoted by this abstract pathname exists. |
| int |
Length() The file’s size. If file doesn’t exist, it will return to 0. |
| boolean |
Mkdir() Creates the directory named by this abstract pathname. |
| boolean |
Mkdirs() Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. |
| boolean |
Rename(String fname) Renames the file denoted by this abstract pathname. |
| void |
CopyTo(NpsFile new_file) If new_file is directory, copy this file to it; else rewrite the new_file. |
| boolean |
Delete() throws Exception Deletes the file or directory denoted by this abstract pathname. |
| void |
OpenReader() throws Exception Open file then enter read mode.You must call CloseReader() or Close() to close reader. |
| int |
Read() throws Exception Read a char. If it reach the stream tail, it will return to -1. |
| String |
ReadLine() throws Exception Read one text line. Certain line is terminated if following characters appear: change line “('\n')”, enter “('\r')”, or change line right after enter. If it reach the stream tail, it will return to “null”. |
| void |
CloseReader() Close Reader。 |
| void |
Reset() throws Exception Reset Reader and Writer. |
| void |
OpenWriter(boolean append) throws Exception Open file then enter read-in mode. set true for append mode. |
| void |
Write(int c) throws Exception Write a char. |
| void |
WriteString(String s) throws Exception Write a string. |
| void |
CloseWriter() Close Writer. |
| void |
Close() Close Reader and Writer simultaneously. |