@ SneakyThrows ( IOException . class ) public static String decompressFromBase64 ( final String base64CompressedString ) { Exceptions . checkNotNullOrEmpty ( base64CompressedString , "base64CompressedString" ) ; try { @ Cleanup final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream ( base64CompressedString . getBytes ( UTF_8 ) ) ; @ Cleanup final InputStream base64InputStream = Base64 . getDecoder ( ) . wrap ( byteArrayInputStream ) ; @ Cleanup final GZIPInputStream gzipInputStream = new GZIPInputStream ( base64InputStream ) ; return IOUtils . toString ( gzipInputStream , UTF_8 ) ; } catch ( ZipException | EOFException e ) { // exceptions thrown for invalid encoding and partial data. throw new IllegalArgumentException ( "Invalid base64 input." , e ) ; } }
Get the original string from its compressed base64 representation .