How to decompress a gzipped data in a byte array?

后端 未结 4 563
别跟我提以往
别跟我提以往 2020-12-02 00:20

I have a class which has a method that is receiving an object as a parameter. This method is invoked via RMI.

public RMIClass extends Serializable {
    pub         


        
相关标签:
4条回答
  • 2020-12-02 00:52

    Look at those samples, and wherever they're using FileOutputStream, use ByteArrayOutputStream instead. Wherever they're using FileInputStream, use ByteArrayInputStream instead. The rest should be simple.

    0 讨论(0)
  • 2020-12-02 01:00

    Why don't you create your own class that extends OutputStream or , whatever is the archive writing to ?

    0 讨论(0)
  • Wrap your byte array with a ByteArrayInputStream and feed it into a GZipInputStream

    0 讨论(0)
  • 2020-12-02 01:04

    If you want to write to a ByteBuffer you can do this.

    private static void uncompress(final byte[] input, final ByteBuffer output) throws IOException
        {
            final GZIPInputStream inputGzipStream = new GZIPInputStream(new ByteArrayInputStream(input));
            Channels.newChannel(inputGzipStream).read(output);
        }
    
    0 讨论(0)
提交回复
热议问题