Example usage for java.lang Float parseFloat

List of usage examples for java.lang Float parseFloat

Introduction

In this page you can find the example usage for java.lang Float parseFloat.

Prototype

public static float parseFloat(String s) throws NumberFormatException 

Source Link

Document

Returns a new float initialized to the value represented by the specified String , as performed by the valueOf method of class Float .

Usage

From source file:Main.java

public static boolean isFaceRate(String string) {
    try {//  w ww  . ja v a  2  s.c om
        float val = Float.parseFloat(string);
        if (val >= 0.1 && val <= 0.9) {
            return true;
        }
    } catch (Exception e) {

    }
    return false;
}

From source file:Main.java

public static float parseFloat(String value) {
    float f = 0;/*  w w  w . j  av a  2  s .c o  m*/
    try {
        f = Float.parseFloat(value);
    } catch (Exception e) {
        // TODO: handle exception
    }

    return f;
}

From source file:Main.java

public static float convertTofloat(String fStr, float defValue) {
    try {//w w w  . j a v a  2s. c  o m
        return Float.parseFloat(fStr);
    } catch (NumberFormatException e) {
    }
    return defValue;
}

From source file:Main.java

public static float parseFloat(String number) {
    float num = 0;
    try {/*from  w w w .  j  a v  a  2 s. com*/
        num = Float.parseFloat(number);
    } catch (Exception e) {
        // TODO: handle exception
    }
    return num;
}

From source file:Main.java

public static float doFloat(Object obj) {
    return obj != null ? Float.parseFloat(obj.toString()) : 0;
}

From source file:Main.java

public static float getFloat(Element element, String attributeName) {

    return Float.parseFloat(element.getAttribute(attributeName));
}

From source file:Main.java

public static float safeParseFloat(String str) {
    float result = 0.f;
    try {/*from www  .j av a 2  s . c  o m*/
        result = Float.parseFloat(str);
    } catch (NumberFormatException e) {
        result = 0.f;
    }
    return result;
}

From source file:Main.java

public static float getFloat(String floatString) {
    float number = 0;
    try {//from w  ww . jav  a 2  s.  c o  m
        number = Float.parseFloat(floatString);
    } catch (Exception e) {
        // TODO: handle exception
    }
    return number;
}

From source file:Main.java

public static float getFloatAttr(NamedNodeMap attributes, String attrName) {
    return Float.parseFloat(getAttr(attributes, attrName));
}

From source file:Main.java

public static float getFloatAttribute(Node node, String name) {
    return Float.parseFloat(getAttribute(node, name, "0"));
}