/**
* Copyright (c) 2010-2013, JGraph Ltd
*/
package com.mxgraph.imageexport;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
/**
* General utilities using for image generation
*/
public class Utils
{
protected static final int IO_BUFFER_SIZE = 4 * 1024;
public static String inflate(byte[] binary) throws IOException
{
StringBuffer result = new StringBuffer();
InputStream in = new InflaterInputStream(new ByteArrayInputStream(
binary), new Inflater(true));
while (in.available() != 0)
{
byte[] buffer = new byte[IO_BUFFER_SIZE];
int len = in.read(buffer, 0, IO_BUFFER_SIZE);
if (len <= 0)
{
break;
}
result.append(new String(buffer, 0, len));
}
in.close();
return result.toString();
}
}