int 转十六进制

//使用1字节就可以表示b
public static String numToHex8(int b) {
        return String.format("%02x", b);//2表示需要两个16进行数
    }
//需要使用2字节表示b
public static String numToHex16(int b) {
        return String.format("%04x", b);
    }
//需要使用4字节表示b
public static String numToHex32(int b) {
        return String.format("%08x", b);
    }


posted @ 2018-10-12 16:56  千彧  阅读(3070)  评论(0编辑  收藏  举报