blob: af04b8ac7780fd3ad84f639255899e2ef65b9316 [file] [log] [blame]
Raph Leviendcecdd82012-03-23 11:21:16 -07001// Copyright 2011 Google Inc. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package com.google.typography.font.compression;
6
7import java.io.ByteArrayOutputStream;
8import java.io.IOException;
9import java.util.zip.Deflater;
10import java.util.zip.DeflaterOutputStream;
11
12/**
13 * Simple utility for GZIP compression
14 */
15public class GzipUtil {
16 public static byte[] deflate(byte[] bytes) {
17 try {
18 ByteArrayOutputStream baos = new ByteArrayOutputStream();
19 DeflaterOutputStream dos = new DeflaterOutputStream(baos, new Deflater());
20 dos.write(bytes, 0, bytes.length);
21 dos.close();
22 return baos.toByteArray();
23 } catch (IOException e) {
24 throw new RuntimeException(e);
25 }
26 }
27}
28