Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

String to Integer Checking

Question posted by: Libra Blue (Guest) on July 17th, 2005 11:02 PM
I have a string in a variable, but I want to check if this string is a
group of characters or actually an integer/double/etc..

Any idea how this should be done??

Libra Blue
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
SPG's Avatar
SPG
Guest
n/a Posts
July 17th, 2005
11:02 PM
#2

Re: String to Integer Checking
try this:


private boolean isNumeric(String checkStr){

try{
Integer.parseInt(checkStr);
return true; //Did not throw, must be a number
}catch(NumberFormatException err){
return false; //Threw, So is not a number
}
}

Suppose you could do same with Double, Float etc

Steve

"Libra Blue" <librablue9@hotmail.com> wrote in message
news:7f44e382.0404190518.5d445d2e@posting.google.c om...[color=blue]
> I have a string in a variable, but I want to check if this string is a
> group of characters or actually an integer/double/etc..
>
> Any idea how this should be done??
>
> Libra Blue[/color]



Libra Blue's Avatar
Libra Blue
Guest
n/a Posts
July 17th, 2005
11:02 PM
#3

Re: String to Integer Checking
Thanks a lot

Libra Blue

"SPG" <steve.nospoo.goodsell@nopoo.blueyonder.co.uk> wrote in message news:<xTQgc.2843$9t.27767833@news-text.cableinet.net>...[color=blue]
> try this:
>
>
> private boolean isNumeric(String checkStr){
>
> try{
> Integer.parseInt(checkStr);
> return true; //Did not throw, must be a number
> }catch(NumberFormatException err){
> return false; //Threw, So is not a number
> }
> }
>
> Suppose you could do same with Double, Float etc
>
> Steve
>
> "Libra Blue" <librablue9@hotmail.com> wrote in message
> news:7f44e382.0404190518.5d445d2e@posting.google.c om...[color=green]
> > I have a string in a variable, but I want to check if this string is a
> > group of characters or actually an integer/double/etc..
> >
> > Any idea how this should be done??
> >
> > Libra Blue[/color][/color]

 
Not the answer you were looking for? Post your question . . .
170,099 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors