private StringBuffer byteArrayToString ( Charset charset , byte [ ] minified ) throws IOException { // Write the data into a string ReadableByteChannel chan = Channels . newChannel ( new ByteArrayInputStream ( minified ) ) ; Reader rd = Channels . newReader ( chan , charset . newDecoder ( ) , - 1 ) ; StringWriter writer = new StringWriter ( ) ; IOUtils . copy ( rd , writer , true ) ; return writer . getBuffer ( ) ; }
Convert a byte array to a String buffer taking into account the charset