Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

byte array to zip java

public static byte[] zipBytes(String filename, byte[] input) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipOutputStream zos = new ZipOutputStream(baos);
    ZipEntry entry = new ZipEntry(filename);
    entry.setSize(input.length);
    zos.putNextEntry(entry);
    zos.write(input);
    zos.closeEntry();
    zos.close();
    return baos.toByteArray();
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #byte #array #zip #java
ADD COMMENT
Topic
Name
8+3 =