/*This program reads in a string from the keyboard, chops the string into tokens,
* checks each character in the token to see if they are ALL digits( no 7B or 5! ).
* /
public static void main(String[] args)
{
boolean itIsAnInt= true;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter int values separated by spaces: ");//make it user friendly
String str = keyboard.nextLine( );
Scanner sc = new Scanner(str); //So we can break the string into tokens (parts)
while( sc.hasNext( ) )
{
String temp = sc.next(); //read in a token
for(int i = 0; i < temp.length( ); i++)
{
if( !Character.isDigit(temp.charAt(i) ) //If a token contains a caharcter that is not a digit
{ System.out.println( "Error: Not an int value!");
itIsAnInt= false;
break;
}
}//end of for-loop
if( itIsAnInt ) //The token had all digits so it is an int
{
System.out.println("The Int is:" + Integer.valueOf(temp);
}
}//End of while-loop
} //End of main method