String str = "adfadfasdfas";
 byte[] bytes = str.getBytes() ;随便你取几个了

解决方案 »

  1.   

    String是unicode的呀,前是个字符就是都是双字节的
      

  2.   

    moumouren(某某人) ,那得到了bytes 怎样把bytes 的前10个字节放到另一个String 中去。
      

  3.   

    String newS = new String( yourBytes );
      

  4.   

    String newS = new String( yourBytes, 0, 10 );
      

  5.   

    如果你就是想把一个String中的一部分取出来的话,这样就可以
    String newS = str.subString(0, 11 );
    这样就会取出0-10的字符。另外,java用unicode,不用考虑byte和全角半角。他总是2byte一个char.
      

  6.   

    DanielYWoo(绿色毒汁)的方法不行吧,subString按字符取,不符合要求。XKP(低等下人) 的方法我忙上去试,回头结分。
      

  7.   

    String(byte[] bytes, int offset, int length) 
             -->  Constructs a new String by decoding the specified subarray of bytes using the platform's default charset.默认编码String(byte[] bytes, int offset, int length, String charsetName) 
              Constructs a new String by decoding the specified subarray of bytes using the specified charset