Java tutorial
//package com.java2s; public class Main { public static int parseStringToInt(String sContent, int iDefaultValue) { try { int iRes = Integer.parseInt(sContent); return iRes; } catch (NumberFormatException e) { e.printStackTrace(); return iDefaultValue; } } }