List of usage examples for java.util.zip InflaterInputStream read
public int read(byte[] b, int off, int len) throws IOException
From source file:zipB64.java
protected static String decodeMessage(String encodedMessage) { try {//from w w w . j a v a 2 s .c o m Base64 b = new Base64(); byte[] decodedBase64 = b.decode(encodedMessage.getBytes()); // Decompress the bytes ByteArrayInputStream bytesIn = new ByteArrayInputStream(decodedBase64); InflaterInputStream inflater = new InflaterInputStream(bytesIn); int nbRead = 0; StringBuilder sb = new StringBuilder(); while (nbRead >= 0) { byte[] result = new byte[500]; nbRead = inflater.read(result, 0, result.length); if (nbRead > 0) { sb.append(new String(result, 0, nbRead, "UTF-8")); } } return sb.toString(); } catch (Exception e) { return "zut"; } }
From source file:Main.java
public static byte[] zlibDecompress(InputStream is) { if (null == is) return null; InflaterInputStream iis = new InflaterInputStream(is); ByteArrayOutputStream o = new ByteArrayOutputStream(1024); try {//from w w w . java 2 s. c om int i = 1024; byte[] buf = new byte[i]; while ((i = iis.read(buf, 0, i)) > 0) { o.write(buf, 0, i); } } catch (IOException e) { e.printStackTrace(); } return o.toByteArray(); }