java - InflateInputStream.Read() 在我的应用程序中导致 ANR。我正在尝试从应用程序中解压缩文本文件。此功能在 Intelij 中运行良好
问题描述
我想使用下面的函数从我的应用程序中解压缩文件。当我在 InteliJ 中运行代码时,此功能在我的笔记本电脑上运行良好;但是当我在我的设备上安装应用程序时会导致 ANR。并且无法解压文件。// FileInputStream fis=new FileInputStream(getFilesDir()+"/file1.cmp");
//assign output file: file3 to FileOutputStream for reading the data
FileOutputStream fos=new FileOutputStream(getFilesDir()+"/file3.txt");
//assign inflaterInputStream to FileInputStream for uncompressing the data
InflaterInputStream iis=new InflaterInputStream(fis);
//read data from inflaterInputStream and write it into FileOutputStream
int data;
while((data=iis.read())!=-1)
{
fos.write(data);
}
//close the files
fos.close();
iis.close();
解决方案
推荐阅读
- c++ - 将双指针作为参数传递给期望引用 std::vector 的函数
- html - 如何有一个包含两列、三列或更多列的下拉菜单?
- android - 无法在 android 上运行 react-native 新项目
- c# - 激活触摸屏键盘的派生文本框
- python - 什么是命令行争论以及它们的用途是什么?
- r - 格式化字符列中的小数位。as.numeric 擦除列中的值
- excel - Excel中的文本到列数据拆分
- c - 我的 Clang 编译器采用哪种 C 标准(ANSI、c99...)?
- c# - 在 C# 中重构 if 语句块
- mysql - mySQL80 错误 1045 (28000)::Access Denied for user@localhost (使用密码: YES)