The shortest method will be with Scanner:
private static int readSoleInteger(String path) {
Scanner s = new Scanner(new File(path));
int ret = s.nextInt();
s.close();
return ret;
}
, Scanner IOExceptions, .
" "... , , , , . .
: , . , Scanner .
s.skip("\\s+");
.
2: , Scanner :
, , :
(regexes snipped)
.