Connecting Tech Pros Worldwide Help | Site Map

String to Integer Checking

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 11:02 PM
Libra Blue
Guest
 
Posts: n/a
Default String to Integer Checking

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

  #2  
Old July 17th, 2005, 11:02 PM
SPG
Guest
 
Posts: n/a
Default 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]


  #3  
Old July 17th, 2005, 11:02 PM
Libra Blue
Guest
 
Posts: n/a
Default 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]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.