Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;

public class Main {
    public static float readFloat(Node node, String attributeName, float def) {
        try {
            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;
            }
        }
    }
}