Java Decompress Byte Array decompressStringFromByteArray(byte[] compressedString)

Here you can find the source of decompressStringFromByteArray(byte[] compressedString)

Description

decompress String From Byte Array

License

Open Source License

Declaration

public static String decompressStringFromByteArray(byte[] compressedString) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;
import java.util.zip.GZIPInputStream;

public class Main {
    public static String decompressStringFromByteArray(byte[] compressedString) {
        StringBuilder stringBuilder = new StringBuilder();
        try {//from   ww w  . j a  v a2s. c o  m
            GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(compressedString));
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(gzipInputStream, "UTF-8"));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                stringBuilder.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringBuilder.toString();
    }
}

Related

  1. decompressGzipByteArray(byte[] compressedByteArray)
  2. decompressObject(byte[] bytes)
  3. decompressString(byte[] compressed)
  4. decompressString(byte[] compressedData)
  5. decompressString(byte[] compressedString)