Java tutorial
//package com.java2s; public class Main { /** * For a given string that should contain an integer value, return either * the <code>int</code> value or a zero if empty. * * @param irodsValue * @return <code>int</code> equivilent of irods value */ public static int getIntOrZeroFromIRODSValue(final String irodsValue) { int result = 0; if (irodsValue == null) { throw new IllegalArgumentException("null irodsValue"); } if (irodsValue.isEmpty()) { // nothing } else { try { result = Integer.parseInt(irodsValue); } catch (NumberFormatException nfe) { throw new IllegalArgumentException("cannot format number:" + irodsValue, nfe); } } return result; } }