readTextWithEncoding static method
读取文本文件(指定编码)
Implementation
static Future<String> readTextWithEncoding(
String filePath, Encoding encoding) async {
try {
final file = File(filePath);
if (!await file.exists()) {
throw Exception('File not found: $filePath');
}
return await file.readAsString(encoding: encoding);
} catch (e) {
throw Exception('Failed to read file with encoding: $e');
}
}