public class Test {
public static void main(String args[]) {
int x = 16; //10进制整数
String xStr = new Test().int2Hex(x);
System.out.println(xStr);
}
private String int2Hex(int n) {
StringBuffer strBuf = new StringBuffer();
int high = n >> 8; // 高16位
int low = n & 0x00ff; // 低16位
String highStr = Integer.toHexString(high);
String lowStr = Integer.toHexString(low);
strBuf.append(highStr);
strBuf.append(lowStr);
return new String(strBuf);
}
}