Read local compressed XML file(gzip) in An

2019-02-21 07:25发布

问题:

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

employee.gz

If someone Can help I really appreciate. Thanks

回答1:

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.