在Android应用程序中读取本地压缩XML文件(gzip)

2024-04-02

我不知道如何获得InputStream(读取gzip压缩的本地xml文件)从本地存储gzip xml file.

员工.gz

如果有人可以帮助我真的很感激。谢谢


此链接适用于 zip。http://techdroid.kbeanie.com/2010/10/unzip-files-in-android.html http://techdroid.kbeanie.com/2010/10/unzip-files-in-android.html

我不确定它是否适用于 gz 文件,但你可以尝试一下。开发文档中有关于 GZIPInputStream 类的文档。

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

这段代码有效。



GZIPInputStream inputStream = new GZIPInputStream(new FileInputStream(new File(
                        "path to file")));

String str = IOUtils.convertStreamToString(inputStream);
  

我使用了一个 util 类,它将输入流转换为字符串。您可能想手动完成阅读部分。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在Android应用程序中读取本地压缩XML文件(gzip) 的相关文章

随机推荐