public static String addBinary(String a, String b) {
        StringBuffer sb = new StringBuffer();
        int alen = a.length();
        int blen = b.length();
        int isin = 0;
        int i = 0, j = 0;
        for (i = alen - 1, j = blen - 1; i >= 0 && j >= 0; i--, j--) {
        	int ac = a.charAt(i) - '0';
        	int bc = b.charAt(j) - '0';
        	int sum = isin + ac + bc;
        	sb.insert(0, sum % 2);
        	isin = sum / 2;
        }
        for (; i >= 0; i--) {
        	int sum = a.charAt(i) - '0' + isin;
        	sb.insert(0, sum % 2);
        	isin = sum / 2;
        }
        for (; j >= 0; j--) {
        	int sum = b.charAt(j) - '0' + isin;
        	sb.insert(0, sum % 2);
        	isin = sum / 2;
        }
        if (1 == isin) sb.insert(0, "1");
    	return sb.toString();
    }