dcsimg

How do I initialize an int from a string of binary digits?

John Zukowski

To go from something like "0101010101" to the int equivalent, use the Integer.parseInt(binaryString, 2) method. If you prefer to go to an Integer, instead of an int, use Integer.valueOf(binaryString, 2) instead. The 2 represents the radix, or base of the number.