Here you can find the source of toFloat(String value, Float defaultValue)
public static Float toFloat(String value, Float defaultValue)
//package com.java2s; //License from project: Open Source License public class Main { public static Float toFloat(String value, Float defaultValue) { if (isEmpty(value)) return defaultValue; try {/* w w w . j a v a 2 s . c o m*/ return Float.parseFloat(value); } catch (Exception e) { return defaultValue; } } public static boolean isEmpty(String str) { if (str == null) return true; if ("".equals(str.trim())) return true; return false; } }