Here you can find the source of bytesToChars(byte[] data, String enc)
Parameter | Description |
---|---|
data | the byte array |
enc | its encoding |
public static char[] bytesToChars(byte[] data, String enc)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w .j av a2s . c o m*/ * Convert byte array to char array * @param data the byte array * @param enc its encoding * @return the equivalent char array */ public static char[] bytesToChars(byte[] data, String enc) { String str; try { str = new String(data, enc); } catch (Exception e) { str = new String(data); } char[] chars = new char[str.length()]; str.getChars(0, chars.length, chars, 0); return chars; } }