public static byte[] changeEncoding(byte[] byteArray,Charset charsetFrom,Charset charsetTo){
  ByteBuffer inputBuffer=ByteBuffer.wrap(byteArray);
  CharBuffer data=charsetFrom.decode(inputBuffer);
  ByteBuffer outputBuffer=charsetTo.encode(data);
  return outputBuffer.array();
}

public static byte [ ] changeEncoding ( byte [ ] byteArray , Charset charsetFrom , Charset charsetTo ) { ByteBuffer inputBuffer = ByteBuffer . wrap ( byteArray ) ; CharBuffer data = charsetFrom . decode ( inputBuffer ) ; ByteBuffer outputBuffer = charsetTo . encode ( data ) ; return outputBuffer . array ( ) ; }
usage : charset charsetfrom = charset . forname ( " utf - 8 " ) ; charset charsetto = charset . forname ( " iso - 8859 - 15 " ) ;
