String str = "abc";
byte[] b = str.getBytes();
for (int i = 0, size = b.length; i < size; i++)
  System.out.println((char)b[i]);

解决方案 »

  1.   

    String str="hello";
          
    try{    System.out.println(str.getBytes("US-ASCII"));}
    catch(UnsupportedEncodingException e)
    {System.out.println("the charset is not supported");}
      

  2.   

    UnsupportedEncodingException需要import java.io.*;
      

  3.   

    Byte.valueof(String str) 这样不行吗?
      

  4.   

    用这个就好了
    String str = "abc";
    byte[] b = str.getBytes();
    for (int i = 0, size = b.length; i < size; i++)
      System.out.println((char)b[i]);
      

  5.   

    Byte.valueof(String str)这样不行吗?