Added isInteger().
git-svn-id: https://samskivert.googlecode.com/svn/trunk@655 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -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
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// 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
|
* Converts the supplied object to a string. Normally this is
|
||||||
* accomplished via the object's built in <code>toString()</code>
|
* accomplished via the object's built in <code>toString()</code>
|
||||||
|
|||||||
Reference in New Issue
Block a user