Android examples for java.lang:Float
safe Parse Float
import android.text.TextUtils; public class Main{ public static float safeParseFloat(String str, float fallback) { if (str == null) { // this check is needed for proper deserialization return fallback; }//from w w w . java 2 s . com try { return Float.valueOf(str); } catch (NumberFormatException e) { ULog.d(TAG, String.format("Cannot parse float from %s.", str)); return fallback; } } }