I'm new to Java and I need to create a method checking that byte stream contains even number. I've already written some code, but I think it's horrible, and don't know how to test it. It seems to me there is some short and efficient way to do that check...
public boolean isNumber(InputStream in) {
boolean evenNum = false;
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String input;
int num;
try {
input = reader.readLine();
num = Integer.parseInt(input);
if (num % 2 == 0) {
evenNum = true;
}
} catch (IOException e) {
e.printStackTrace();
}
return evenNum;
}