FileInputStream read文件后 文件清零怎办?

mickyo 2020-05-29 07:52:45
如下函数,读取文件后,文件变成0B,怎么会这样,怎么破?

//以字节流读取文件*/
public byte[] getByteStream(){
try{
File file = new File(mCurrentFilePath);
// 拿到输入流
FileInputStream input = new FileInputStream(file);
// 建立存储器
byte[] buf =new byte[input.available()];
// 读取到存储器
input.read(buf);
input.close();// 关闭输入流
// 返回数据
return buf;
}catch(Exception e){
e.printStackTrace();
}
return null;
}
...全文
706 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hacker_crazy 2020-06-13
  • 打赏
  • 举报
回复
创建了file,byte数组大小使用file.length不就行了。这个方法本身不会改变file文件的
mickyo 2020-06-11
  • 打赏
  • 举报
回复
来个人回复下,好散分
mickyo 2020-06-04
  • 打赏
  • 举报
回复
来个人回复下,好散分

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧