请在此代码中提供帮助以仅指定整数的输入.......................... …………………………………………………………………………………………
int shape=0;
boolean inp=false;
while (! inp) {
try
{
shape = (int)(System.in.read()-'0');
}//try
catch (IOException e)
{
System.out.println("error");
System.out.println("Please enter the value again:");
}//catch
if ((shape == 1) || (shape == 2)) {
inp = true;
}//if
}//while