Java tutorial
//package com.java2s; public class Main { public static float safeParseFloat(String str) { float result = 0.f; try { result = Float.parseFloat(str); } catch (NumberFormatException e) { result = 0.f; } return result; } }