可以用String的charAt提出每个char,转换成int,再用Integer的static String toHexString(int i) 方法转成16进制数就可以了。
如:
String result="";
for(int i=0;i<strPhoto.length();i++){
    char c=strPhoto.charAt(i);
    int i=c;
    String hex=Integer.toHexString(i);
    result+=hex;
}

解决方案 »

  1.   

    String strPhoto = "ABCD";
        String str="";
        char ch[]=strPhoto.toCharArray();
        for(int i=0;i<ch.length;i++)
        {
          int asc=ch[i];
          str=str+Integer.toHexString(asc);
        }
         System.out.println(str);
      

  2.   

    把数据库中的图片转成字符串InputStream is=rst.getBinaryStream("F1");
    byte by[]=new byte[is.available()];
    is.read(by);
    String strPhoto = new String(by);