private byte [ ] readStreamCompressed ( InputStream stream ) throws IOException { ByteArrayOutputStream bao = new ByteArrayOutputStream ( ) ; GZIPOutputStream gos = new GZIPOutputStream ( bao ) ; OutputStreamWriter output = new OutputStreamWriter ( gos ) ; BufferedReader input = new BufferedReader ( new InputStreamReader ( stream ) ) ; String line ; while ( ( line = input . readLine ( ) ) != null ) { output . write ( line ) ; output . write ( ' ' ) ; } input . close ( ) ; stream . close ( ) ; output . close ( ) ; gos . close ( ) ; bao . close ( ) ; return bao . toByteArray ( ) ; }
Reads the given text stream and compressed its content .