Why does my program ignore zeros when reading from a file? For example, here are the numbers from the file:
0001 0011 0010
Then this is my output:
1
11
10
This is my code:
File file = new File("num.txt");
Scanner scanner = new Scanner(file);
while (scanner.hasNext()) {
if (scanner.hasNextInt()) {
System.out.println(scanner.nextInt());
} else {
scanner.next();
}
}