标签:blog java ar 2014 log c file as r
public static String bin2Hex(String binStr) { int deci = Integer.valueOf(binStr,2); return Integer.toHexString(deci); } public static String hex2Bin(String hexStr) { int deci = Integer.valueOf(hexStr,16); return Integer.toBinaryString(deci); }
public static void main(String args[]) { String str = "f012"; System.out.println(hex2Bin(str)); System.out.println(bin2Hex("01011011")); }
1111000000010010
5b
非常简单
8进制同理,转换
通过Integer类实现二进制和16进制之间的互相转换,8进制同理
标签:blog java ar 2014 log c file as r
原文地址:http://blog.csdn.net/simonchi/article/details/39008807