Here you can find the source of toInt(String value)
public static int toInt(String value)
//package com.java2s; //License from project: Open Source License public class Main { public static int toInt(String value) { if (!isBinary(value)) return 0; if (value.length() > 31) return Integer.MAX_VALUE; return Integer.parseInt(value, 2); }/* w ww . ja v a 2s .c o m*/ public static boolean isBinary(String binary) { if (binary == null || binary.length() == 0) return false; for (char c : binary.toCharArray()) if (!(c == '0' || c == '1')) return false; return true; } }