I\'m apparently facing an infinite loop on while(input.hasNext()) , as in following code
while(input.hasNext())
File file = new File(\"data.txt\"); Scanner input = new Sca
You do not need to double checking on content. this should work:
File file = new File("data.txt"); Scanner input = new Scanner(file); int sum = 0; while(input.hasNextInt()) { sum += input.nextInt(); } System.out.println(sum);
Hope this helps.