DOCUMENTS 5 - PortalScripting API
|
The File class allows full access to files stored on the Portal Server's filesystem. More...
Public Member Functions | |
boolean | close () |
Close the file handle. More... | |
boolean | eof () |
Report whether the file pointer points to EOF (end of file). More... | |
String | error () |
Retrieve the error message of the last file access error as String. More... | |
File | File (String pathFileName, String mode) |
The constructor has the purpose to open a file handle to the desired file. More... | |
boolean | ok () |
Report whether an error occurred while accessing the file handle. More... | |
String | read (int charsNo) |
Retrieve a block of data from the file, containing a maximum of charsNo byte. More... | |
String | readLine () |
Retrieve one line of data from the file. More... | |
boolean | write (number[] byteArray) |
Write binary data to the file. More... | |
boolean | write (string a, string b,...) |
Write data to the file. More... | |
boolean | writeBuffer (String data, int charsNo) |
Write data to the file. More... | |
The File class allows full access to files stored on the Portal Server's filesystem.
File File::File | ( | String | pathFileName, |
String | mode | ||
) |
The constructor has the purpose to open a file handle to the desired file.
Once created, you cannot change the access mode of the file handle. If you need to change the access mode, you would have to close the file and reopen it.
pathFileName | String value containing the complete path and filename of the desired file |
mode | String representing the access mode for the file handle. Allowed values are:
|
boolean File::close | ( | ) |
Close the file handle.
true
if successful, false
in case of any error boolean File::eof | ( | ) |
Report whether the file pointer points to EOF (end of file).
true
if EOF, false
if not String File::error | ( | ) |
Retrieve the error message of the last file access error as String.
The error message (as long there is one) and its language depend on the operating system used on the Portal Server's machine. If there is no error, the method returns null
.
null
in case of no error boolean File::ok | ( | ) |
Report whether an error occurred while accessing the file handle.
true
if no error occurred, false
in case of any error String File::read | ( | int | charsNo | ) |
Retrieve a block of data from the file, containing a maximum of charsNo
byte.
After the method has been performed, the data pointer of the file handle is moved right after the block which has been read. This might as well trigger the EOF flag, if the end of file has been reached.
charsNo | integer value indicating how many characters (resp. byte in binary mode) should be read |
charsNo
characters/byte of data of the file. String File::readLine | ( | ) |
Retrieve one line of data from the file.
This method requires to have the file opened in text mode to work flawlessly, because the end of line is recognized by the linefeed character. After the readLine() method has been performed, the data pointer of the file handle is moved to the beginning of the next line of data.
boolean File::write | ( | number [] | byteArray | ) |
Write binary data to the file.
This requires to have the file handle opened with write access (meaning modes r+
, w/w+
, a/a+
) and binary mode b
.
byteArray | Array of integers containing any data you want to write to the file |
true
if successful, false
in case of any error boolean File::write | ( | string | a, |
string | b, | ||
... | |||
) |
Write data to the file.
This requires to have the file handle opened with write access (meaning modes r+
, w/w+
, a/a+
). You may concatenate as many strings as you want.
a | String containing any data you want to write to the file |
b | String containing any data you want to write to the file |
true
if successful, false
in case of any error boolean File::writeBuffer | ( | String | data, |
int | charsNo | ||
) |
Write data to the file.
This requires to have the file handle opened with write access (meaning modes r+
, w/w+
, a/a+
).
data | String containing any data you want to write to the file. |
charsNo | integer value indicating how many characters should be written. |
true
if successful, false
in case of any error