flutter - Flutter:读取文件内容
问题描述
我正在基于现有的 iOS 应用程序(在 appStore 上发布)创建一个 Flutter 应用程序,我需要读取旧 iOS 应用程序(notes.data)中现有文件的内容,我做了什么:
String fileName = "notes.data";
String dir = (await getApplicationDocumentsDirectory()).path;
String savePath = '$dir/$fileName';
if (await File(savePath).exists()) {
print("File exists");
var readAsBytes = await File(savePath).readAsBytesSync();
print(utf8.decode(readAsBytes));
}
它打印文件存在,但我无法获取文件的内容。
请提供任何帮助。
解决方案
推荐阅读
- android - Uri resultUri = result.getUri(); (getUri() 是红色的,当我将鼠标悬停在它上面时,它说:无法解析 ActivityResult 中的 getUri 方法
- html - 使用ajax作为测试监控工具:“加载资源失败:服务器响应状态为404”
- java - Cordova 构建失败,不确定为什么会发生
- java - 检查没有 getInputType 的自定义视图的输入类型
- javascript - Firestore 时间戳 toDate() 返回错误的 UTC 日期?
- postman - 使用 MS bot 框架在 JIRA 中上传附件
- python - 自定义负损失可能性在不同数量的训练后返回 NaN
- mysql - 如何按日期对两个选择进行排序?
- php - 如何按行中的元素进行迭代
- python - (最佳实践)在一个视图中处理与一个对象相关的多个简单表单