public static byte[] packEntry(File file) {
    log.trace("Compressing '{}' into a ZIP file with single entry.", file);

    ByteArrayOutputStream result = new ByteArrayOutputStream();
    try {
      ZipOutputStream out = new ZipOutputStream(result);
      ZipEntry entry = ZipEntryUtil.fromFile(file.getName(), file);
      InputStream in = new BufferedInputStream(new FileInputStream(file));
      try {
        ZipEntryUtil.addEntry(entry, in, out);
      }
      finally {
        IOUtils.closeQuietly(in);
      }
      out.close();
    }
    catch (IOException e) {
      throw ZipExceptionUtil.rethrow(e);
    }
    return result.toByteArray();
  }
public static byte [ ] packEntry ( File file ) { log . trace ( "Compressing '{}' into a ZIP file with single entry." , file ) ; ByteArrayOutputStream result = new ByteArrayOutputStream ( ) ; try { ZipOutputStream out = new ZipOutputStream ( result ) ; ZipEntry entry = ZipEntryUtil . fromFile ( file . getName ( ) , file ) ; InputStream in = new BufferedInputStream ( new FileInputStream ( file ) ) ; try { ZipEntryUtil . addEntry ( entry , in , out ) ; } finally { IOUtils . closeQuietly ( in ) ; } out . close ( ) ; } catch ( IOException e ) { throw ZipExceptionUtil . rethrow ( e ) ; } return result . toByteArray ( ) ; }
Compresses the given file into a ZIP file with single entry.

@param file file to be compressed.
@return ZIP file created.