Search in sources :

Example 51 with DataFormatException

use of java.util.zip.DataFormatException in project geode by apache.

the class CommandResult method saveIncomingFiles.

public void saveIncomingFiles(String directory) throws IOException {
    // dump file data if any
    try {
        GfJsonObject content = getContent();
        if (content != null) {
            GfJsonArray bytesArray = content.getJSONArray(CompositeResultData.BYTE_DATA_ACCESSOR);
            AbstractResultData.readFileDataAndDump(bytesArray, directory);
        } else {
            // TODO Abhishek - add i18n
            throw new RuntimeException("No associated files to save .. ");
        // string
        }
        numTimesSaved = numTimesSaved + 1;
    } catch (DataFormatException e) {
        throw new RuntimeException(e);
    } catch (GfJsonException e) {
        throw new RuntimeException(e);
    }
}
Also used : GfJsonArray(org.apache.geode.management.internal.cli.json.GfJsonArray) DataFormatException(java.util.zip.DataFormatException) GfJsonObject(org.apache.geode.management.internal.cli.json.GfJsonObject) GfJsonException(org.apache.geode.management.internal.cli.json.GfJsonException)

Example 52 with DataFormatException

use of java.util.zip.DataFormatException in project bitsquare by bitsquare.

the class Utils method decompress.

private static byte[] decompress(byte[] compressedData, int length) {
    Inflater inflater = new Inflater();
    inflater.setInput(compressedData, 0, length);
    ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
    byte[] buf = new byte[8192];
    while (!inflater.finished()) {
        try {
            int count = inflater.inflate(buf);
            bos.write(buf, 0, count);
        } catch (DataFormatException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
    try {
        bos.close();
    } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    return bos.toByteArray();
}
Also used : DataFormatException(java.util.zip.DataFormatException) Inflater(java.util.zip.Inflater) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

DataFormatException (java.util.zip.DataFormatException)52 IOException (java.io.IOException)24 Inflater (java.util.zip.Inflater)23 ByteBuffer (java.nio.ByteBuffer)9 ArrayList (java.util.ArrayList)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 ByteBuf (io.netty.buffer.ByteBuf)2 PooledByteBuffer (io.undertow.connector.PooledByteBuffer)2 EOFException (java.io.EOFException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ZipException (java.util.zip.ZipException)2 ILoader (master.flame.danmaku.danmaku.loader.ILoader)2 IllegalDataException (master.flame.danmaku.danmaku.loader.IllegalDataException)2 Danmakus (master.flame.danmaku.danmaku.model.android.Danmakus)2 BaseDanmakuParser (master.flame.danmaku.danmaku.parser.BaseDanmakuParser)2 BadPayloadException (org.eclipse.jetty.websocket.api.BadPayloadException)2 Response (org.jsoup.helper.HttpConnection.Response)2 OrcCorruptionException (com.facebook.presto.orc.OrcCorruptionException)1