转载请注明出处:http://blog.csdn.net/u013258802/article/details/53010157
照着《Android开发艺术探索》一书敲Serializable接口的例子时,遇到 FileNotFoundException
例子很简单就是往文件里存个User对象:
User user = new User(0, "liang", true); ObjectOutputStream out = null; try { out = new ObjectOutputStream(new FileOutputStream("test.txt")); out.writeObject(user); out.close(); } catch (IOException e) { e.printStackTrace(); }
这段抛出异常:FileNotFoundException: Caused by: android.system.ErrnoException: open failed: EROFS (Read-only file system)
看起来感觉像缺少权限,不过跟权限没什么关系。
搜到一篇文章:
高赞回答说:
Please use the version of the FileOutputStream</