Java examples for java.lang:String Parse
safe Parse Int
//package com.java2s; public class Main { public static void main(String[] argv) { String toParse = "java2s.com"; System.out.println(safeParseInt(toParse)); }//from w ww. j ava2 s .c o m public static Integer safeParseInt(String toParse) { try { return Integer.valueOf(toParse); } catch (NumberFormatException e) { return null; } } }