File Extension
File System Extension
The File extension provides robust file system operations. You can access it using an instance approach or static path-based operations.
Instance Approach
# Open a file
f = new File();
f.uuid = File.openfile("test.txt");
# Write and Read
f.writeText("Hello World");
content = f.readText();
print(content); # "Hello World"
# Close file
f.close();
Static / Path-Based Operations
File.writeText("test2.txt", "Direct write");
if (File.exists("test2.txt")) {
print(File.readText("test2.txt"));
File.delete("test2.txt");
}
Instance Methods (on File struct)
- Closes the file.
- Reads the entire content as a string.
- Reads the file line by line into an array.
- Writes string content to the file.
- Appends string content to the file.
- Checks if the file exists.
- Deletes the file.
Static / Package Methods
- Opens a file and returns a UUID handle (string).
- Reads text from path.
- Reads lines from path.
- Writes text to path.
- Appends text to path.
- Checks if path exists.
- Deletes file at path.
- Creates a directory.
- Lists files in a directory.