首页 > 解决方案 > 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(); 

标签: javaandroid

解决方案


推荐阅读