Class File
Represents a file. This class is not available in CRM Online.
Use open() before you call any other methods.Examples
File f;
f.open("test.txt", "a+"); // Opening file appending (and creating)
f.write("test");
f.close(); // Closing the file when done writing
File g;
g.open("test.txt", "r"); // Opening file for reading only
print(g.readAll());
Constructors
File()
Initializes a new instance of the File class.
Declaration
File Examples
File f;
f.open("test.txt", "a+"); // Opening file appending (and creating)
f.write("test");
f.close(); // Closing the file when done writing
File g;
g.open("test.txt", "r"); // Opening file for reading only
print(g.readAll());
Methods
close()
Closes the file. The File object is then ready to open a new file.
Declaration
Void close() Returns
| Type | Description |
| Void |
eof()
Returns true if a read passed the end of file has been attempted.
Declaration
Bool eof() Returns
| Type | Description |
| Bool | True if a read passed the end of file has been attempted; otherwise, false. |
flush()
Empties the output buffer, writing the data to the file.
Declaration
flush() Returns
| Type | Description |
| Void |
open(String,String)
Opens the file to be available for other calls.
Declaration
Bool open(String filename, String mode) Parameters
| Type | Name | Description |
| String | filename | Path to the file |
| String | mode | How to open the file. |
Returns
| Type | Description |
| Bool |
open(String,String,String)
Opens the file with a codepage to be available for other calls.
Declaration
Bool open(String filename, String mode, String codepage) Parameters
| Type | Name | Description |
| String | filename | Path to the file |
| String | mode | How to open the file |
| String | codepage | What text codepage the file is in. Default is ISO-8859-1 (Latin-1), but UTF-8 is common for Unicode text files. |
Returns
| Type | Description |
| Bool |
readAll()
Returns all text from the file.
Declaration
String readAll() Returns
| Type | Description |
| String |
readBinary()
Reads the file and returns binary data in a Byte array.
Declaration
Byte readBinary() Returns
| Type | Description |
| Byte[] | Binary data. |
readLine()
Returns the next line from the file or a null string if no more data in the file.
Declaration
String readLine() Returns
| Type | Description |
| String | The next line from the file or a null string if no more data in the file. |
rewind()
Sets the current file pointer to the beginning of the file.
Declaration
Void rewind() Returns
| Type | Description |
| Void |