Here you can find the source of readInt(Node node, String attributeName, int def)
public static int readInt(Node node, String attributeName, int def)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Node; public class Main { public static int readInt(Node node, String attributeName, int def) { try {// w w w. j av a 2 s . c o m return Integer.parseInt(node.getAttributes().getNamedItem(attributeName).getNodeValue()); } catch (Exception ex) { return def; } } /** * Parses an integer from a string, if the string is null returns def. * * @param i The string to parse * @param def The default value if the string is null * @return * @throws SAXException */ public static int parseInt(String i, int def) { if (i == null) { return def; } else { try { return Integer.parseInt(i); } catch (NumberFormatException ex) { return 0; } } } public static int parseInt(String i) { if (i == null) { return 0; } else { try { return Integer.parseInt(i); } catch (NumberFormatException ex) { return 0; } } } }