Java Utililty Methods Decompress Byte Array

List of utility methods to do Decompress Byte Array

  1. HOME
  2. Java
  3. D
  4. Decompress Byte Array

Description

The list of methods to do Decompress Byte Array are organized into topic(s).

Method

String decompress(byte[] byteArray)
decompress
return decompress(new ByteArrayInputStream(byteArray));
T decompress(byte[] bytes)
Decompress a compressed object
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
T object = null;
try (GZIPInputStream gzipIn = new GZIPInputStream(bais);
 ObjectInputStream objectIn = new ObjectInputStream(gzipIn)) {
 object = (T) objectIn.readObject();
} catch (IOException | ClassNotFoundException e) {
 describeException(e, "Exception in Util.decompress");
return object;
byte[] decompress(byte[] bytes)
Decompress byte array
inflater.setInput(bytes);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(bytes.length);
byte[] buffer = new byte[1024];
while (!inflater.finished()) {
 int count = inflater.inflate(buffer);
 outputStream.write(buffer, 0, count);
outputStream.close();
...
String Decompress(byte[] bytes)
Decompress
Inflater decompressor = new Inflater();
decompressor.setInput(bytes);
ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length);
byte[] buffer = new byte[1024];
try {
 while (true) {
 int count = decompressor.inflate(buffer);
 if (count > 0) {
...
byte[] decompress(byte[] bytes)
decompress
try (InputStream in = new InflaterInputStream(new ByteArrayInputStream(bytes))) {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 byte[] buffer = new byte[4096];
 int len;
 while ((len = in.read(buffer)) > 0) {
 baos.write(buffer, 0, len);
 return baos.toByteArray();
...
String decompress(byte[] bytes)
decompress
if (bytes == null || bytes.length == 0) {
 return null;
GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes));
BufferedReader bf = new BufferedReader(new InputStreamReader(gis, "UTF-8"));
String outStr = "";
String line;
while ((line = bf.readLine()) != null) {
...
byte[] decompress(byte[] bytes)
Decompresses an array of bytes.
if (bytes == null || bytes.length == 0) {
 return bytes;
try {
 InputStream in = getInputStream(bytes);
 ByteArrayOutputStream bos = new ByteArrayOutputStream();
 while (in.available() > 0) {
 bos.write(in.read());
...
T decompress(byte[] bytes, int bufferSize)
Decompresses the given byte[] and returns the Object.
try {
 ByteArrayOutputStream bos = new ByteArrayOutputStream(bufferSize);
 Inflater inflater = new Inflater();
 inflater.setInput(bytes);
 byte[] buf = new byte[bufferSize];
 while (!inflater.finished()) {
 int count = inflater.inflate(buf);
 bos.write(buf, 0, count);
...
byte[] decompress(byte[] compressed)
decompress
int nRead;
byte[] data = new byte[2048];
ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
GZIPInputStream gzip = new GZIPInputStream(bis);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
while ((nRead = gzip.read(data, 0, data.length)) != -1) {
 buffer.write(data, 0, nRead);
bis.close();
gzip.close();
return buffer.toByteArray();
String decompress(byte[] compressed)
decompress
if (compressed == null)
 return null;
ByteArrayOutputStream out = null;
ByteArrayInputStream in = null;
ZipInputStream zin = null;
String decompressed;
try {
 out = new ByteArrayOutputStream();
...


AltStyle によって変換されたページ (->オリジナル) /