List of usage examples for java.util.zip Inflater setInput
public void setInput(ByteBuffer input)
From source file:org.getspout.spout.packet.PacketCustomMultiBlockOverride.java
public void decompress() { if (compressed) { Inflater decompressor = new Inflater(); decompressor.setInput(data); ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length); byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { }//from w w w . jav a 2 s .c om } try { bos.close(); } catch (IOException e) { } compressed = false; data = bos.toByteArray(); } }
From source file:org.getspout.spoutapi.packet.PacketCacheFile.java
public void decompress() { if (compressed) { Inflater decompressor = new Inflater(); decompressor.setInput(fileData); ByteArrayOutputStream bos = new ByteArrayOutputStream(fileData.length); byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { }/* w w w . jav a 2s .c om*/ } try { bos.close(); } catch (IOException e) { } fileData = bos.toByteArray(); } }
From source file:org.getspout.spout.packet.PacketBlockData.java
public void decompress() { if (compressed) { Inflater decompressor = new Inflater(); decompressor.setInput(data); ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length); byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { }/*from www. j a v a2 s .co m*/ } try { bos.close(); } catch (IOException e) { } data = bos.toByteArray(); } }
From source file:org.getspout.spoutapi.packet.PacketCustomMultiBlockOverride.java
@Override public void decompress() { if (compressed) { Inflater decompressor = new Inflater(); decompressor.setInput(data); ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length); byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { }//from w w w . ja v a 2 s . c o m } try { bos.close(); } catch (IOException e) { } data = bos.toByteArray(); } }
From source file:org.jasig.cas.web.flow.FrontChannelLogoutActionTests.java
@Test public void verifyLogoutOneLogoutRequestNotAttempted() throws Exception { final String fakeUrl = "http://url"; final LogoutRequest logoutRequest = new LogoutRequest(TICKET_ID, new SimpleWebApplicationServiceImpl(fakeUrl)); WebUtils.putLogoutRequests(this.requestContext, Arrays.asList(logoutRequest)); this.requestContext.getFlowScope().put(FrontChannelLogoutAction.LOGOUT_INDEX, 0); final Event event = this.frontChannelLogoutAction.doExecute(this.requestContext); assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId()); final List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext); assertEquals(1, list.size());/*from w w w . j a v a 2 s . co m*/ final String url = (String) event.getAttributes().get("logoutUrl"); assertTrue(url.startsWith(fakeUrl + "?SAMLRequest=")); final byte[] samlMessage = CompressionUtils.decodeBase64ToByteArray( URLDecoder.decode(StringUtils.substringAfter(url, "?SAMLRequest="), "UTF-8")); final Inflater decompresser = new Inflater(); decompresser.setInput(samlMessage); final byte[] result = new byte[1000]; decompresser.inflate(result); decompresser.end(); final String message = new String(result); assertTrue(message .startsWith("<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\"")); assertTrue(message.indexOf("<samlp:SessionIndex>" + TICKET_ID + "</samlp:SessionIndex>") >= 0); }
From source file:org.getspout.spoutapi.packet.PacketBlockData.java
public void decompress() { if (compressed) { Inflater decompressor = new Inflater(); decompressor.setInput(data); ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length); byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { }/*w ww. j av a2s . c o m*/ } try { bos.close(); } catch (IOException e) { } data = bos.toByteArray(); } }
From source file:org.getspout.spoutapi.packet.PacketCustomBlockChunkOverride.java
@Override public void decompress() { if (compressed && hasData) { Inflater decompressor = new Inflater(); decompressor.setInput(data); ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length); byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { }//from w w w. ja va2 s . c om } try { bos.close(); } catch (IOException e) { } data = bos.toByteArray(); } }
From source file:org.getspout.spout.packet.PacketCacheFile.java
public void decompress() { if (compressed) { Inflater decompressor = new Inflater(); decompressor.setInput(fileData); ByteArrayOutputStream bos = new ByteArrayOutputStream(fileData.length); byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { }/*w w w . ja v a2 s.com*/ } try { bos.close(); } catch (IOException e) { } fileData = bos.toByteArray(); } }
From source file:org.getspout.spoutapi.packet.PacketAddonData.java
@Override public void decompress() { if (compressed) { Inflater decompressor = new Inflater(); decompressor.setInput(data); ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length); byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { }//from w ww . j a va2 s. c o m } try { bos.close(); } catch (IOException e) { } data = bos.toByteArray(); compressed = false; } }
From source file:com.nary.Debug.java
public static Object loadClass(InputStream _inStream, boolean _uncompress) { ObjectInputStream ois;/* w ww. jav a 2 s . com*/ try { if (_uncompress) { // we need to get the input as a byte [] so we can decompress (inflate) it. Inflater inflater = new Inflater(); ByteArrayOutputStream bos; int bytesAvail = _inStream.available(); if (bytesAvail > 0) { bos = new ByteArrayOutputStream(bytesAvail); } else { bos = new ByteArrayOutputStream(); } byte[] buffer = new byte[1024]; int read = _inStream.read(buffer); while (read > 0) { bos.write(buffer, 0, read); read = _inStream.read(buffer); } bos.flush(); inflater.setInput(bos.toByteArray()); bos.reset(); buffer = new byte[1024]; int inflated = inflater.inflate(buffer); while (inflated > 0) { bos.write(buffer, 0, inflated); inflated = inflater.inflate(buffer); } bos.flush(); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ois = new ObjectInputStream(bis); } else { ois = new ObjectInputStream(_inStream); } return ois.readObject(); } catch (Exception E) { return null; } finally { try { _inStream.close(); } catch (Exception ioe) { } } }