Convert byte to 16 binary
public static String Getbyte2str (Byte b) {
byte[] buff = new byte[2];
Buff[0] = mhex[(b >> 4) & 0x0f];
BUFF[1] = mhex[b & 0x0f];
return new String (buff);
}
private static final byte[] Mhex = "0123456789ABCDEF". GetBytes ();
16 binary conversion to 10 binary
int integerstate = integer.valueof (Getbyte2str (macstate), 16);
10 binary conversion to 2 binary string
String s=integer.tobinarystring (integerstate); Binary string
2 binary string converted to 10 binary
String AA = "1010";
Integer f = integer.parseint (aa,2);
In Java, the default is decimal when declaring numbers, you can precede a number with a symbol to indicate that the number is octal "preceded by 0 (0)" or hexadecimal "preceded by 0x (0 x)".
Java's integer wrapper class integer and long provide the ToString (int i,int radix) static method, which converts an arbitrarily-entered integer into another binary integer.
Use the Tobinarystring method of integer or long to convert integers to binary.
Converts an integer to octal using the Tooctalstring method of an integer or long.
Use the Tohexstring method of integer or long to convert integers to 16 binary.
Use the ToString (int i) method of an integer or long to convert other binary integers to a string representation of a decimal integer.
Android binary conversion to each other