diff --git a/projects/samskivert/src/java/com/samskivert/util/StringUtil.java b/projects/samskivert/src/java/com/samskivert/util/StringUtil.java index 6687847c..381aec07 100644 --- a/projects/samskivert/src/java/com/samskivert/util/StringUtil.java +++ b/projects/samskivert/src/java/com/samskivert/util/StringUtil.java @@ -1,5 +1,5 @@ // -// $Id: StringUtil.java,v 1.32 2002/03/08 02:40:02 mdb Exp $ +// $Id: StringUtil.java,v 1.33 2002/03/15 18:05:36 shaper Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -94,6 +94,21 @@ public class StringUtil } } + /** + * Returns whether the supplied string represents an integer value by + * attempting to parse it with {@link Integer#parseInt}. + */ + public static boolean isInteger (String value) + { + try { + Integer.parseInt(value); + return true; + } catch (NumberFormatException nfe) { + // fall through + } + return false; + } + /** * Converts the supplied object to a string. Normally this is * accomplished via the object's built in toString()