Here you can find the source of atoi(final String s, final int def)
public static int atoi(final String s, final int def)
//package com.java2s; //License from project: Open Source License public class Main { public static int atoi(final String s, final int def) { int result = 0; int i = 0; final int len = s.length(); int digit; while (i < len) { digit = s.charAt(i++) - '0'; if (digit < 0 || 9 < digit) return def; result = result * 10 + digit; }//from w ww . jav a 2 s .c o m return result; } }