I would like to know what is null test in java? How to rewrite the below code by avoiding null test. I was asked this question in an online test. I'll be grateful for any help offered.
String mystere() throws IOException {
InputStream input = null;
try {
input = new InputStream(new File("foo.txt"));
return new Scanner(input).nextLine();
} finally {
if (input != null)
input.close();
}
}