Android: read a GZIP file in the ASSETS folder

后端 未结 6 1403
不思量自难忘°
不思量自难忘° 2021-01-06 08:07

How can you read GZIP file in Android located in the \"ASSETS\" (or resources/raw) folder?

I have tried the following code, but my stream size is always 1.



        
6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-06 08:43

    What happens if you use AssetManager instead of Resources? Example:

    InputStream is = mContext.getAssets().open("myfilegz");
    GZIPInputStream fIn = new GZIPINputStream(is);
    

    Internally, Resources is just calling AssetManager; I wonder if somewhere along the way it musses things up.

提交回复
热议问题