2进制转10进制
String e1= "00000010";
int e2 = Integer.parseInt(e1.trim(), 2);//获取的2进制转换成十进制
十六进制转2进制
public class hexString2binryString {
public static String hexString2binaryString(String hexString) {
if (hexString == null || hexString.length() % 2 != 0)
return null;
String bString = "", tmp;
for (int i = 0; i < hexString.length(); i++) {
tmp = "0000"
+ Integer.toBinaryString(Integer.parseInt(//十六进制转10,十进制转2
hexString.substring(i, i + 1), 16));
bString += tmp.substring(tmp.length() - 4);
}
return bString;
}
public static void main(String[] args) {
System.out.println(hexString2binaryString("04"));
}
}