毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 开发语言 >> 正文

解压Unexpected end of ZLIB input stream

更新时间:2016-3-22:  来源:毕业论文

            n = gunzip.read(buffer);
            while ((n = gunzip.read(buffer)) >= 0) {
                out.write(buffer, 0, n);
            }
            des = out.toString();
        } catch (IOException e) {
            e.printStackTrace();
        }finally{
            if(gunzip!=null)
            { 急性脑出血中西医结合综合治疗方案与效果
                try {
                    gunzip.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return des;
    }
压缩用Deflater类。

原来是获得输出流的数据之前,需要将gzip关闭。

另外,我上面说的压缩到16,是因为之前出现异常,所以才那么小。其实应该是8百多

public static String GetCompress(String src)
    {
        if (src == null || src.isEmpty()) {
                        return src;
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream gzip = null;
        String des = null;
        try { 2015幼儿园教师节活动方案 
            gzip = new GZIPOutputStream(out);
            gzip.write(src.getBytes());
                        //由于压缩后的数据需要传输,所以用了BASE64编码
            //des = new BASE64Encoder().encode(out.toByteArray()); //原先在这个获得压缩数据
        } catch (IOException e) {
            e.printStackTrace();
        }finally{
            if(gzip!=null)
            {
                try {
                    gzip.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return new BASE64Encoder().encode(out.toByteArray());//最终改成这里获得压缩数据
    }

上一页  [1] [2] 

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。