比较简单的办法 char[]->String->byte[]

解决方案 »

  1.   

    new String(char[]),String.getBytes()
    实现起来比较简单,效率可能差了一些
      

  2.   

    你看这样能不能满足你的要求:public class CharToByte {
      public static void main(String[] args) {
        char[] chars = {'A','B','C','D','E','F','G'};
        byte[] bytes = new byte[chars.length];
        for(int i= 0; i< chars.length; i++) {
          bytes[i]  = (byte)chars[i];
        }
        for(int i= 0; i< bytes.length; i++) {
          System.out.print(bytes[i] + " ");
        }
      }
    }