private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int read() throws IOException { if (pointer == -1) { try { length = doRead(readBuffer, 0, readBuffer.length); if (length == 0) { return -1; } pointer = 0; } catch (DataFormatException e) { IOException e2 = new IOException(e.getMessage()); e2.initCause(e); throw e2; } } int value = readBuffer[pointer] & 0xFF; pointer++; if (pointer == length) { pointer = -1; } return value; }
@Test public void testInflaterReader() throws Exception { String inputString = "blahblahblah??blahblahblahblahblah??blablahblah??blablahblah??bla"; byte[] input = inputString.getBytes(StandardCharsets.UTF_8); byte[] output = new byte[30]; Deflater compressor = new Deflater(); compressor.setInput(input); compressor.finish(); int compressedDataLength = compressor.deflate(output); byte[] zipBytes = new byte[compressedDataLength]; System.arraycopy(output, 0, zipBytes, 0, compressedDataLength); ByteArrayInputStream byteInput = new ByteArrayInputStream(zipBytes); ArrayList<Integer> holder = new ArrayList<>(); try (InflaterReader inflater = new InflaterReader(byteInput)) { int read = inflater.read(); while (read != -1) { holder.add(read); read = inflater.read(); } } byte[] result = new byte[holder.size()]; for (int i = 0; i < result.length; i++) { result[i] = holder.get(i).byteValue(); } String txt = new String(result); assertEquals(inputString, txt); }
private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int read() throws IOException { if (pointer == -1) { try { length = doRead(readBuffer, 0, readBuffer.length); if (length == 0) { return -1; } pointer = 0; } catch (DataFormatException e) { IOException e2 = new IOException(e.getMessage()); e2.initCause(e); throw e2; } } int value = readBuffer[pointer] & 0xFF; pointer++; if (pointer == length) { pointer = -1; } return value; }
private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int read() throws IOException { if (pointer == -1) { try { length = doRead(readBuffer, 0, readBuffer.length); if (length == 0) { return -1; } pointer = 0; } catch (DataFormatException e) { IOException e2 = new IOException(e.getMessage()); e2.initCause(e); throw e2; } } int value = readBuffer[pointer] & 0xFF; pointer++; if (pointer == length) { pointer = -1; } return value; }
private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int read() throws IOException { if (pointer == -1) { try { length = doRead(readBuffer, 0, readBuffer.length); if (length == 0) { return -1; } pointer = 0; } catch (DataFormatException e) { IOException e2 = new IOException(e.getMessage()); e2.initCause(e); throw e2; } } int value = readBuffer[pointer] & 0xFF; pointer++; if (pointer == length) { pointer = -1; } return value; }
private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int read() throws IOException { if (pointer == -1) { try { length = doRead(readBuffer, 0, readBuffer.length); if (length == 0) { return -1; } pointer = 0; } catch (DataFormatException e) { IOException e2 = new IOException(e.getMessage()); e2.initCause(e); throw e2; } } int value = readBuffer[pointer] & 0xFF; pointer++; if (pointer == length) { pointer = -1; } return value; }
private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int read() throws IOException { if (pointer == -1) { try { length = doRead(readBuffer, 0, readBuffer.length); if (length == 0) { return -1; } pointer = 0; } catch (DataFormatException e) { IOException e2 = new IOException(e.getMessage()); e2.initCause(e); throw e2; } } int value = readBuffer[pointer] & 0xFF; pointer++; if (pointer == length) { pointer = -1; } return value; }
private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int read() throws IOException { if (pointer == -1) { try { length = doRead(readBuffer, 0, readBuffer.length); if (length == 0) { return -1; } pointer = 0; } catch (DataFormatException e) { IOException e2 = new IOException(e.getMessage()); e2.initCause(e); throw e2; } } int value = readBuffer[pointer] & 0xFF; pointer++; if (pointer == length) { pointer = -1; } return value; }