Java 8 GZIPOutputStream - 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 GZIPOutputStream class.

This code example shows how to use the following methods:
			GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(gzJsFile.getFile()));
			FileCopyUtils.copy(jsFile.getInputStream(), out);
		} 
 
		if (gzFingerPrintedFile.getFile().createNewFile()) {
			GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(gzFingerPrintedFile.getFile()));
			FileCopyUtils.copy(fingerPrintedFile.getInputStream(), out);
		} 
 
		assertTrue(gzJsFile.exists());
		assertTrue(gzFingerPrintedFile.exists());
	} 
 
	@Before 
	public void setUp() { 
		Map<String, VersionStrategy> versionStrategyMap = new HashMap<>();
		versionStrategyMap.put("/**", new ContentVersionStrategy());
		VersionResourceResolver versionResolver = new VersionResourceResolver();
		versionResolver.setStrategyMap(versionStrategyMap);
 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: finish
    } 
 
    public static InputStream compressGzip(String contentEncoding, InputStream in) throws IOException {
        if (isGzip(contentEncoding)) {
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            GZIPOutputStream gzip = new GZIPOutputStream(os);
            try { 
                IOHelper.copy(in, gzip);
                gzip.finish();
                return new ByteArrayInputStream(os.toByteArray());
            } finally { 
                IOHelper.close(gzip, "gzip");
                IOHelper.close(os, "byte array output stream");
            } 
        } else { 
            return in;
        } 
    } 
 
    public static InputStream compressGzip(String contentEncoding, byte[] data) throws IOException {
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
  private HttpServletResponse response;
  private GZIPOutputStream out;
 
  public GZIPResponseStream(HttpServletResponse response) throws IOException {
    this.response = response;
    this.out = new GZIPOutputStream(response.getOutputStream());
    response.addHeader("Content-Encoding", "gzip");
  } 
 
  public void resetBuffer() { 
    if (out != null && !response.isCommitted()) {
      response.setHeader("Content-Encoding", null);
    } 
    out = null;
  } 
 
  @Override 
  public void write(int b) throws IOException {
    out.write(b);
  } 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: finish
    } 
 
    public void compressTo(InputStream in, OutputStream out) throws CompressException {
        GZIPOutputStream gzipOut = null;
        try { 
            gzipOut = new GZIPOutputStream(out);
            NioUtils.copy(in, gzipOut);
            gzipOut.finish(); //需要使用finish
        } catch (Exception e) {
            throw new CompressException("gzip_compress_error", e);
        } 
    } 
 
    public void decompressTo(InputStream in, OutputStream out) throws CompressException {
        GZIPInputStream gzipin = null;
        try { 
            gzipin = new GZIPInputStream(in);
            NioUtils.copy(gzipin, out);
            out.flush();
        } catch (Exception e) {
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
        @edu.umd.cs.findbugs.annotations.SuppressWarnings({ "OS_OPEN_STREAM" }) 
        public void write(final ObjectDataOutput out, final Object obj) throws IOException {
            final ObjectOutputStream objectOutputStream;
            final OutputStream outputStream = (OutputStream) out;
            if (gzipEnabled) {
                objectOutputStream = new ObjectOutputStream(new GZIPOutputStream(outputStream));
            } else { 
                objectOutputStream = new ObjectOutputStream(outputStream);
            } 
            if (shared) {
                objectOutputStream.writeObject(obj);
            } else { 
                objectOutputStream.writeUnshared(obj);
            } 
            // Force flush if not yet written due to internal behavior if pos < 1024 
            objectOutputStream.flush();
        } 
    } 
 
    public static final class EnumSerializer extends SingletonSerializer<Enum> {
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 GZIPOutputStream Questions & Answers:

See Code Examples for Java 8 GZIPOutputStream Methods: