晕,帮帮你 应该是:ab大cd家e|好f 首先要知道编码,中国汉字一般使用GBK或者gb2312,gb2312是GBK的子集,因此安全起见使用GBK一般就行了:
public class Decoder { public static void main(String[]args){ String result=decodeString(args[0], "GBK"); System.out.println(result); } private static String decodeString(String string, String encoding) { try { byte[]data=string2Bytes(string); return new String(data, encoding); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); return null; } } private static byte[] string2Bytes(String string) { int blen=string.length()/2; byte[]data=new byte[blen]; for(int i=0;i<blen;i++){ String bStr=string.substring(2*i,2*(i+1)); data[i]=(byte)Integer.parseInt(bStr,16); } return data; } }
运行: java Decoder 6162B4F36364BCD2657CBAC366 |