public static boolean IsNumeric(String s){
for(int i=0;i<s.length();i++){
if(s.charAt(i) < '0' || s.charAt(i)> '9' ){
return false;
}
}
return true;
}
then all you have to do is...
if(IsNumeric)num=Integer.parseInt(String s);
else System.out.println("This is not a number Man!!);