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