gzipinputstream

Android: read a GZIP file in the ASSETS folder

ⅰ亾dé卋堺 提交于 2019-11-30 22:39:28
How can you read GZIP file in Android located in the "ASSETS" (or resources/raw) folder? I have tried the following code, but my stream size is always 1. GZIPInputStream fIn = new GZIPInputStream(mContext.getResources().openRawResource(R.raw.myfilegz)); int size = fIn.available(); for some reason the size is always 1. But if Idon't GZIP the file, it works fine. NOTE: Using Android 1.5 I met the same problem when reading a gz file from assets folder. It's caused by the file name of the gz file. Just renaming yourfile.gz to other name like yourfile.bin. It seems Android build system would

Gets the uncompressed size of this GZIPInputStream?

时光总嘲笑我的痴心妄想 提交于 2019-11-30 18:45:16
I have a GZIPInputStream that I constructed from another ByteArrayInputStream . I want to know the original (uncompressed) length for the gzip data. Although I can read to the end of the GZIPInputStream , then count the number, it will cost much time and waste CPU. I would like to know the size before read it. Is there a similiar method like ZipEntry.getSize() for GZIPInputStream : public long getSize () Since: API Level 1 Gets the uncompressed size of this ZipEntry. Is there a similiar method like ZipEntry.getSize() for GZIPInputStream No. It's not in the Javadoc => it doesn't exist. What do

Android: read a GZIP file in the ASSETS folder

女生的网名这么多〃 提交于 2019-11-30 17:56:46
问题 How can you read GZIP file in Android located in the "ASSETS" (or resources/raw) folder? I have tried the following code, but my stream size is always 1. GZIPInputStream fIn = new GZIPInputStream(mContext.getResources().openRawResource(R.raw.myfilegz)); int size = fIn.available(); for some reason the size is always 1. But if Idon't GZIP the file, it works fine. NOTE: Using Android 1.5 回答1: I met the same problem when reading a gz file from assets folder. It's caused by the file name of the gz

Gets the uncompressed size of this GZIPInputStream?

末鹿安然 提交于 2019-11-30 16:48:40
问题 I have a GZIPInputStream that I constructed from another ByteArrayInputStream . I want to know the original (uncompressed) length for the gzip data. Although I can read to the end of the GZIPInputStream , then count the number, it will cost much time and waste CPU. I would like to know the size before read it. Is there a similiar method like ZipEntry.getSize() for GZIPInputStream : public long getSize () Since: API Level 1 Gets the uncompressed size of this ZipEntry. 回答1: Is there a similiar

Android: decompress string that was compressed with PHP gzcompress()

这一生的挚爱 提交于 2019-11-30 16:37:28
How can i decompress a String that was zipped by PHP gzcompress() function? Any full examples? thx I tried it now like this: public static String unzipString(String zippedText) throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream(zippedText.getBytes("UTF-8")); GZIPInputStream gzis = new GZIPInputStream(bais); InputStreamReader reader = new InputStreamReader(gzis); BufferedReader in = new BufferedReader(reader); String unzipped = ""; while ((unzipped = in.readLine()) != null) unzipped+=unzipped; return unzipped; } but it's not working if i i'm trying to unzip a PHP gzcompress

GZIPInputStream fails with IOException in Android 2.3, but works fine in all previous releases?

本小妞迷上赌 提交于 2019-11-30 05:21:43
问题 I updated my phone to Gingerbread today (2.3.2) and fired up an app I developed and saw that it failed to load its data. The app runs fine on every other version of Android I have tested from 1.6 to 2.2, but then an IOException in Gingerbread. Does anybody know if something changed in either GZipInputStream or URL.openStream()? The problematic code is similar to the following: InputStream in = null; GZIPInputStream zin = null; URL url = null; try { url = new URL("http://www.test.com/gzipped

Gets the uncompressed size of this GZIPInputStream?

我是研究僧i 提交于 2019-11-30 02:11:46
问题 I have a GZIPInputStream that I constructed from another ByteArrayInputStream . I want to know the original (uncompressed) length for the gzip data. Although I can read to the end of the GZIPInputStream , then count the number, it will cost much time and waste CPU. I would like to know the size before read it. Is there a similiar method like ZipEntry.getSize() for GZIPInputStream : public long getSize () Since: API Level 1 Gets the uncompressed size of this ZipEntry. 回答1: Is there a similiar

GZIPInputStream to String

别等时光非礼了梦想. 提交于 2019-11-29 22:13:56
First of all, I'm sorry if my terminology is a bit amateur, try to bear with me ;) I am attempting to convert the gzipped body of a HTTP response to plaintext. I've taken the byte array of this response and converted it to a ByteArrayInputStream. I've then converted this to a GZIPInputStream. I now want to read the GZIPInputStream and store the final decompressed HTTP response body as a plaintext String. This code will store the final decompressed contents in an OutputStream, but I want to store the contents as a String: public static int sChunk = 8192; ByteArrayInputStream bais = new

Java: Error creating a GZIPInputStream: Not in GZIP format

社会主义新天地 提交于 2019-11-29 10:26:54
I am trying to use the following Java code to compress and uncompress a String. But the line that creates a new GZipInputStream object out of a new ByteArrayInputStream object throws a "java.util.zip.ZipException: Not in GZIP format" exception. Does anyone know how to solve this? String orig = "............."; // compress it ByteArrayOutputStream baostream = new ByteArrayOutputStream(); OutputStream outStream = new GZIPOutputStream(baostream); outStream.write(orig.getBytes()); outStream.close(); String compressedStr = baostream.toString(); // uncompress it InputStream inStream = new

Java: Error creating a GZIPInputStream: Not in GZIP format

核能气质少年 提交于 2019-11-28 03:38:13
问题 I am trying to use the following Java code to compress and uncompress a String. But the line that creates a new GZipInputStream object out of a new ByteArrayInputStream object throws a "java.util.zip.ZipException: Not in GZIP format" exception. Does anyone know how to solve this? String orig = "............."; // compress it ByteArrayOutputStream baostream = new ByteArrayOutputStream(); OutputStream outStream = new GZIPOutputStream(baostream); outStream.write(orig.getBytes()); outStream.close