在 Android 应用程序中读取本地压缩的 XML 文件(gzip) [英] Read local compressed XML file(gzip) in Android application
问题描述
我不知道如何从本地存储的 gzip xml
文件中获取 InputStream
(读取 gzipped 本地 xml 文件).
employee.gz
如果有人可以帮助我真的很感激.谢谢
此链接适用于 zip.http://techdroid.kbeanie.com/2010/10/unzip-files-in-android.html
我不确定它是否适用于 gz 文件,但您可以尝试一下.开发文档上有关于 GZIPInputStream 类的文档.
http://developer.android.com/reference/java/util/zip/GZIPInputStream.html
这段代码有效.
<上一页>GZIPInputStream inputStream = new GZIPInputStream(new FileInputStream(new File(文件路径")));String str = IOUtils.convertStreamToString(inputStream);我使用了一个将输入流转换为字符串的 util 类.您可能希望手动完成阅读部分.
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
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.
这篇关于在 Android 应用程序中读取本地压缩的 XML 文件(gzip)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!