byte[] byt = str.getBytes();or use System.ArrayCopy.....

解决方案 »

  1.   

    String str ="abcdefg";
    byte[] byt =new byte[20];
    改为:
    String str ="abcdefg";
    byte[] byt =str.getBytes();如果不想这样你也可以用个循环来getByte();
      

  2.   

    getBytes
    public byte[] getBytes()
    Convert this String into bytes according to the platform's default character encoding, storing the result into a new byte array.
    Returns:
    the resultant byte array.
    Since: 
    JDK1.1 
    摘自java的帮助文档,多看看文档对学java帮助很大。
      

  3.   

    getBytes
    public byte[] getBytes()
    Convert this String into bytes according to the platform's default character encoding, storing the result into a new byte array.
    Returns:
    the resultant byte array.
    Since: 
    JDK1.1 
    摘自java的帮助文档,多看看文档对学java帮助很大。
      

  4.   

    getBytes
    public byte[] getBytes()
    Convert this String into bytes according to the platform's default character encoding, storing the result into a new byte array.
    Returns:
    the resultant byte array.
    Since: 
    JDK1.1 
    多看看java文档,对学习java帮助会很大
      

  5.   

    我试过byte[] byt =str.getBytes("Unicode");
    原来不用加参数,谢了,给分!