java - java.io.IOException:只读文件系统,在android虚拟设备上测试时
问题描述
当我在 android studio 上测试 android 虚拟设备java.io.IOException: Read-only file system
时,尝试写入文件时出现错误。我想这是因为程序正在尝试将文件创建/写入到测试文件上的虚拟 android 设备上,但话虽如此,我不知道如何将文件保存到“本地”文件系统,比如“C:_tmp_output.json”。
我还添加了使用权限android.permission.READ_EXTERNAL_STORAGE
行,但没有像我预期的那样工作。有人会帮我解决这个问题吗?谢谢你。
File test = new File("C:\\_tmp\\_output.json");
test.createNewFile() ;
FileWriter file = new FileWriter("C:\\_tmp\\_output.json");
file.write(String.valueOf("foobar"));
解决方案
推荐阅读
- excel - 输入框搜索用户表单记录然后从工作表中删除?
- pdf - 在 Chrome 中呈现但在 Acrobat 中不呈现的 PDF
- php - 如何用符号 _ 完成 html 行
- python - 如何在 Python MXNet 中查找内存泄漏?
- powershell - 如何删除每个任务的所有任务触发器?
- javascript - 需要一个空类,在同一目录中
- wpf - 您可以为路径的各个部分设置样式吗?
- mpdf - 解析使用 GD 库创建的临时文件图像对象以解析 PNG 图像的 PNG 图像时出错
- firebase - 使用颤振(或 Android)的 Firebase 存储规则
- sql - 如何更快地搜索一个有 8000 万条记录的表?