Read local compressed XML file(gzip) in Android application

前端 未结 1 473
野性不改
野性不改 2021-01-17 01:10

I don\'t know how to get an InputStream(Read gzipped local xml file) from the locally stored gzip xml file.

employee.gz

相关标签:
1条回答
  • 2021-01-17 01:34

    This link works with zip. http://techdroid.kbeanie.com/2010/10/unzip-files-in-android.html

    I am not sure if it will work with gz files, but you could give it a try. There's a documentation on GZIPInputStream class on the dev docs.

    http://developer.android.com/reference/java/util/zip/GZIPInputStream.html

    This piece of code works.

    GZIPInputStream inputStream = new GZIPInputStream(new FileInputStream(new File(
                            "path to file")));
    
    String str = IOUtils.convertStreamToString(inputStream);
    

    I have used a util class which converts the input stream to a string. You might want to do the reading part manually.

    0 讨论(0)
提交回复
热议问题