JAVA怎样将文字转成ASCII码,请各位仁兄指教.
  比如:
String str="人生";
  然后我想将它转成--》 人生不知该怎么转哪?

解决方案 »

  1.   

    package com.redtroy;/**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2005</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */public class String2ASCII {
      public String2ASCII() {
      }
      public static void main(String[] args) {
        String src="人生";
        char [] bytes=new char[src.length()];
        src.getChars(0,src.length(),bytes,0);
        for(int i=0;i<bytes.length;i++){
          System.out.print((int)bytes[i]+";");
        }
      }}