public static String inputStreamToString ( InputStream is ) throws MPException { String value = "" ; if ( is != null ) { try { ByteArrayOutputStream result = new ByteArrayOutputStream ( ) ; byte [ ] buffer = new byte [ 1024 ] ; int length ; while ( ( length = is . read ( buffer ) ) != - 1 ) { result . write ( buffer , 0 , length ) ; } value = result . toString ( "UTF-8" ) ; } catch ( Exception ex ) { throw new com . mercadopago . exceptions . MPException ( ex ) ; } } return value ; }
Static method that transform an Input Stream to a String object returns an empty string if InputStream is null .