boxlang-file-handlinglisted
Install: claude install-skill ortus-boxlang/skills
# BoxLang File Handling
## Overview
BoxLang provides comprehensive file-system operations for reading, writing, and
managing files and directories. Supports text, binary, and streaming access with
configurable encoding.
## Reading Files
```boxlang
// Read entire file as string
var content = fileRead( "/path/to/file.txt" )
// Read with explicit encoding
var content = fileRead( "/path/to/file.txt", "UTF-8" )
// Read as array of lines
var lines = fileReadLines( "/path/to/file.txt" )
lines.each( ( line ) -> println( line ) )
// Read binary file
var bytes = fileReadBinary( "/path/to/image.jpg" )
```
### Streaming Large Files
```boxlang
function processLargeFile( filePath ) {
var file = fileOpen( filePath, "read" )
try {
while ( !fileIsEOF( file ) ) {
processLine( fileReadLine( file ) )
}
} finally {
fileClose( file )
}
}
```
## Writing Files
```boxlang
// Write (create or replace)
fileWrite( "/path/to/file.txt", "Hello World" )
// Write with encoding
fileWrite( "/path/to/file.txt", content, "UTF-8" )
// Append to file
fileWrite( "/path/to/file.txt", "New line\n", "UTF-8", true )
// Write binary
fileWriteBinary( "/path/to/image.jpg", binaryData )
```
### Buffered Write for Large Content
```boxlang
function writeLargeFile( filePath, lines ) {
var file = fileOpen( filePath, "write" )
try {
lines.each( ( line ) -> fileWriteLine( file, line ) )
} finally {
fileClose( file )
}
}
```
## C