readFile function
Read the entire content of a text file as a single string.
This function reads all lines from the specified file and joins them with newline characters to create a single string containing the complete file content.
Parameters:
path: Path to the file to read
Returns a string containing the entire file content.
Throws:
- Exception if the file doesn't exist
- Exception if there are insufficient permissions to read the file
- Exception if the file is a directory
Example:
final content = readFile('/path/to/file.txt');
print(content);
Implementation
String readFile(String path) {
return read(path).join('\n');
}