Here you can find the source of bin2dec(String bin)
private static int bin2dec(String bin)
//package com.java2s; /*/*from w ww.j a va2 s . c o m*/ * (C) Copyright IBM Corp. 2008 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ public class Main { private static int bin2dec(String bin) { int dec = 0, n = 1; for (int i = bin.length() - 1; i >= 0; i--) { dec += n * ('1' == bin.charAt(i) ? 1 : 0); n <<= 1; } return dec; } }