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

This code example shows how to use the following methods: close, finish, write
	} 
 
	public static byte[] deflateByteArray(byte[] input) {
		try { 
			ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length);
			DeflaterOutputStream out = new DeflaterOutputStream(bos);
 
			out.write(input, 0, input.length);
 
			out.finish();
			out.close();
 
			byte[] compressedData = bos.toByteArray();
			return compressedData;
		} 
		catch (IOException e) {
			return null; 
		} 
	} 
 
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: write, putNextEntry, write, close
            manifest.write(manOut);
            byte[] manBytes = manOut.toByteArray();
            File file = File.createTempFile(
                    Support_PlatformFile.getNewPlatformFile("hyts_manifest1", 
                            ""), ".jar"); 
            JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(
                    file.getAbsolutePath()));
            ZipEntry entry = new ZipEntry("META-INF/");
            entry.setSize(0);
            jarOut.putNextEntry(entry);
            entry = new ZipEntry(JarFile.MANIFEST_NAME);
            entry.setSize(manBytes.length);
            jarOut.putNextEntry(entry);
            jarOut.write(manBytes);
            entry = new ZipEntry("myfile");
            entry.setSize(1);
            jarOut.putNextEntry(entry);
            jarOut.write(65);
            jarOut.close();
            JarFile jar = new JarFile(file.getAbsolutePath(), false);

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: write, close, finish
This code example shows how to use the following methods: close
			throw ERT.badarg(bin);
		} 
		 
		Deflater defl = new Deflater();
		BARR bos = new BARR();
		DeflaterOutputStream dos = new DeflaterOutputStream(bos, defl);
		 
		try { 
			b.writeTo(dos);
			dos.close();
		} catch (IOException e) {
			throw new InternalError("should not happen");
		} 
		 
		return bos.asBinary();		
	} 
	 
	static private class BARR extends ByteArrayOutputStream {
		EBinary asBinary() { 
			return new EBinary(super.buf, 0, super.count);
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: close, finish, write
	 
	public static NSData gzipByteArrayAsNSData(byte[] input, int offset, int length) {
		try { 
			ERXRefByteArrayOutputStream bos = new ERXRefByteArrayOutputStream(length);
			if (input != null) {
				GZIPOutputStream out = new GZIPOutputStream(bos);
	 
				out.write(input, offset, length);
	 
				out.finish();
				out.close();
			} 
			return bos.toNSData();
		} 
		catch (IOException e) {
			log.error("Failed to gzip byte array.", e);
			return null; 
		} 
	} 
 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 DeflaterOutputStream Questions & Answers:

See Code Examples for Java 8 DeflaterOutputStream Methods: