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