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);
}
}
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();
}
Aggregations