Connecting Tech Pros Worldwide Help | Site Map

String to Integer Checking

  #1  
Old July 18th, 2005, 12:02 AM
Libra Blue
Guest
 
Posts: n/a
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 18th, 2005, 12:02 AM
SPG
Guest
 
Posts: n/a

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 18th, 2005, 12:02 AM
Libra Blue
Guest
 
Posts: n/a

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]
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
String to integer Freaker85 answers 13 August 26th, 2006 10:25 AM
convert string to int djozy answers 24 November 15th, 2005 05:20 PM
Converting from char to integer value hantie answers 22 November 13th, 2005 06:11 PM
Converting a string to an integer Alex Neumann answers 6 July 22nd, 2005 11:47 AM