Here you can find the source of readFloat(Node node, String attributeName, float def)
public static float readFloat(Node node, String attributeName, float def)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Node; public class Main { public static float readFloat(Node node, String attributeName, float def) { try {//from w w w. j av a 2 s . co m return Float.parseFloat(node.getAttributes().getNamedItem(attributeName).getNodeValue()); } catch (Exception ex) { return def; } } public static float parseFloat(String f, float def) { if (f == null) { return def; } else { try { return Float.parseFloat(f); } catch (NumberFormatException ex) { return 0; } } } public static float parseFloat(String f) { if (f == null) { return 0; } else { try { return Float.parseFloat(f); } catch (NumberFormatException ex) { return 0; } } } }