blob: 75fac1b31843572d9a31002c9d9852abebd998b7 [file] [log] [blame]
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package com.google.typography.font.compression;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;
/**
* Simple utility for GZIP compression
*
* @author Raph Levien
*/
public class GzipUtil {
public static byte[] deflate(byte[] bytes) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DeflaterOutputStream dos = new DeflaterOutputStream(baos, new Deflater());
dos.write(bytes, 0, bytes.length);
dos.close();
return baos.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}