Here you can find the source of parseBigInteger(String s, BigInteger defaultValue)
public static BigInteger parseBigInteger(String s, BigInteger defaultValue)
//package com.java2s; //License from project: Apache License import java.math.BigInteger; public class Main { public static BigInteger parseBigInteger(String s, BigInteger defaultValue) { String ch = getNumberChars(s); if (ch == null) { return defaultValue; }//from ww w.j a v a 2 s .c om return new BigInteger(ch); } public static String getNumberChars(String s) { if (s == null) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if ('0' <= c && c <= '9') { if (i == 1 && s.charAt(0) == '-') { sb.append('-'); } sb.append(c); } } if (sb.length() == 0) { return null; } else { return sb.toString(); } } }