Java 8 GZIPInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 GZIPInputStream class.

This code example shows how to use the following methods:
	protected InputStream readResponseBody(HttpInvokerClientConfiguration config, HttpURLConnection con)
			throws IOException {
 
		if (isGzipResponse(con)) {
			// GZIP response found - need to unzip. 
			return new GZIPInputStream(con.getInputStream());
		} 
		else { 
			// Plain response found. 
			return con.getInputStream();
		} 
	} 
 
	/** 
	 * Determine whether the given response is a GZIP response. 
	 * <p>Default implementation checks whether the HTTP "Content-Encoding" 
	 * header contains "gzip" (in any casing). 
	 * @param con the HttpURLConnection to check 
	 */ 
	protected boolean isGzipResponse(HttpURLConnection con) {
9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close
        ByteArrayOutputStream baos = null;
 
        try 
        { 
            bais = new ByteArrayInputStream(bytes);
            gzis = new GZIPInputStream(bais);
            baos = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE);
 
            IOUtils.copy(gzis, baos);
            gzis.close();
            bais.close();
 
            byte[] uncompressedByteArray = baos.toByteArray();
            baos.close();
 
            if (logger.isDebugEnabled())
            { 
                logger.debug("Uncompressed message to size: " + uncompressedByteArray.length);
            } 
 

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    readChars(gzis, cbuf, 0, ss.length());
    assertEquals(new String(cbuf), ss);
    // System.out.println("passes w/o FastInputStream"); 
 
    ByteArrayInputStream bis = new ByteArrayInputStream(b.toByteArray(), 0, b.size());
    gzis = new GZIPInputStream(new FastInputStream(bis));
    cbuf = new char[ss.length()];
    readChars(gzis, cbuf, 0, ss.length());
    assertEquals(new String(cbuf), ss);
    // System.out.println("passes w FastInputStream"); 
  } 
 
  //code copied from NamedListCodec#readChars 
  public static void readChars(InputStream in, char[] buffer, int start, int length)
          throws IOException {
    final int end = start + length;
    for (int i = start; i < end; i++) {
      int b = in.read();
      if ((b & 0x80) == 0)
        buffer[i] = (char) b;
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close
  } 
  public static void copyDecompressed(String resource, File output)
      throws IOException {
    URL input =  Resources.getResource(resource);
    FileOutputStream fos = new FileOutputStream(output);
    GZIPInputStream gzis = new GZIPInputStream(input.openStream());
    ByteStreams.copy(gzis, fos);
    fos.close();
    gzis.close();
  } 
 
  public static Context createFileChannelContext(String checkpointDir,
      String dataDir, String backupDir, Map<String, String> overrides) {
    Context context = new Context(); 
    context.put(FileChannelConfiguration.CHECKPOINT_DIR, 
            checkpointDir);
    if(backupDir != null) {
      context.put(FileChannelConfiguration.BACKUP_CHECKPOINT_DIR, backupDir);
    } 
    context.put(FileChannelConfiguration.DATA_DIRS, dataDir);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	 */ 
	protected InputStream getResponseBody(HttpInvokerClientConfiguration config, HttpResponse httpResponse)
			throws IOException {
 
		if (isGzipResponse(httpResponse)) {
			return new GZIPInputStream(httpResponse.getEntity().getContent());
		} 
		else { 
			return httpResponse.getEntity().getContent();
		} 
	} 
 
	/** 
	 * Determine whether the given response indicates a GZIP response. 
	 * <p>The default implementation checks whether the HTTP "Content-Encoding" 
	 * header contains "gzip" (in any casing). 
	 * @param httpResponse the resulting HttpResponse to check 
	 * @return whether the given response indicates a GZIP response 
	 */ 
	protected boolean isGzipResponse(HttpResponse httpResponse) {
9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
        public Object read(final ObjectDataInput in) throws IOException {
            final ObjectInputStream objectInputStream;
            final InputStream inputStream = (InputStream) in;
            if (gzipEnabled) {
                objectInputStream = newObjectInputStream(in.getClassLoader(), new GZIPInputStream(inputStream));
            } else { 
                objectInputStream = newObjectInputStream(in.getClassLoader(), inputStream);
            } 
 
            final Object result; 
            try { 
                if (shared) {
                    result = objectInputStream.readObject();
                } else { 
                    result = objectInputStream.readUnshared();
                } 
            } catch (ClassNotFoundException e) {
                throw new HazelcastSerializationException(e);
            } 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	// Methods for/from SuperClass/Interfaces 
	// =========================================================== 
 
	@Override 
	public GZIPInputStream getInputStream() throws IOException { 
		return new GZIPInputStream(this.onGetInputStream()); 
	} 
 
	// =========================================================== 
	// Methods 
	// =========================================================== 
 
	// =========================================================== 
	// Inner and Anonymous Classes 
	// =========================================================== 
} 
9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close
    return in.read(b, off, len);
  } 
 
  @Override 
  public void close() throws IOException {
    in.close();
  } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close
    } 
  } 
 
  public static byte[] decompress(String bytes) {
    try { 
      GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(Base64.decodeBase64(bytes.getBytes())));
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 
      IOUtils.copy(gzipInputStream, outputStream);
 
      gzipInputStream.close();
 
      return outputStream.toByteArray();
    } catch (IOException e) {
      throw new RuntimeException(e);
    } 
  } 
} 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
import java.util.zip.GZIPOutputStream;
 
public class MemUtil { 
	public static byte[] decompress(byte[] input) throws IOException {
		ByteArrayInputStream bais = new ByteArrayInputStream(input);
		GZIPInputStream gzis = new GZIPInputStream(bais);
		 
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		Util.copyStream(gzis, baos);
		 
		return baos.toByteArray();
	} 
	 
	public static byte[] compress(byte[] input) throws IOException {		
		ByteArrayInputStream bais = new ByteArrayInputStream(input);
		 
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		GZIPOutputStream gzos = new GZIPOutputStream(baos);
		Util.copyStream(bais, gzos);
		gzos.close();
8
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 GZIPInputStream Questions & Answers:

See Code Examples for Java 8 GZIPInputStream Methods: