开发者

Read local compressed XML file(gzip) in Android application

开发者 https://www.devze.com 2023-03-20 11:41 出处:网络
I don\'t know how to 开发者_StackOverflow社区get an InputStream(Read gzipped local xml file) from the locally stored gzip xml file.

I don't know how to 开发者_StackOverflow社区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


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号