GZIPInputStream to String

前端 未结 8 1089
北恋
北恋 2020-12-04 21:49

I am attempting to convert the gzipped body of a HTTP response to plaintext. I\'ve taken the byte array of this response and converted it to a ByteArrayInputStream. I\'ve th

8条回答
  •  伪装坚强ぢ
    2020-12-04 22:35

    you can also do

    try (GZIPInputStream gzipIn = new GZIPInputStream(new ByteArrayInputStream(pByteArray)))
    {
    ....
    }
    

    AutoClosable is a good thing https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html

提交回复
热议问题