The File extension provides robust file system operations. You can access it using an instance approach or static path-based operations.
# 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();
File.writeText("test2.txt", "Direct write");
if (File.exists("test2.txt")) {
print(File.readText("test2.txt"));
File.delete("test2.txt");
}
close(): Closes the file.readText(): Reads the entire content as a string.readLines(): Reads the file line by line into an array.writeText(content): Writes string content to the file.appendText(content): Appends string content to the file.exists(): Checks if the file exists.delete(): Deletes the file.File.openfile(path): Opens a file and returns a UUID handle (string).File.readText(path): Reads text from path.File.readLines(path): Reads lines from path.File.writeText(path, content): Writes text to path.File.appendText(path, content): Appends text to path.File.exists(path): Checks if path exists.File.delete(path): Deletes file at path.File.mkdir(path): Creates a directory.File.list(path): Lists files in a directory.