Android ObjectInputStream(openFileInput) 总是抛出 IOException
我正在尝试从内部存储(文件)中读取数据,但是遇到了问题。
我使用 FileInputStream fis = context.openFileInput(filename)
获得文件的 FileInputStream
。 调用成功,没有任何失败。接下来,我尝试使用以下行创建一个 ObjectInputStream
对象:ObjectInputStream ois = new ObjectInputStream(fis)
。
这每次都会抛出IOException
!我做错了什么?
我尝试使用 fis
作为 FileInputStream
和 InputStream
对象。 我可以使用 ObjectOutputStream
写入文件。
I'm trying to read from internal storage (a file) however i'm having issues.
I get a FileInputStream
for a file using FileInputStream fis = context.openFileInput(filename)
.
The call is successful, nothing fails. Next I try to create an ObjectInputStream
object using the following line: ObjectInputStream ois = new ObjectInputStream(fis)
.
This throws an IOException
EVERY time!! What am I doing wrong?
I've tried using fis
as a FileInputStream
and as an InputStream
object.
I'm able to write to a file using ObjectOutputStream
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论