/*
	This program check for file existence
	
*
*/
 import java.util.*;
 import java.io.*;
 
 public class FileExist
 {
 	public static void main(String[] args)throws IOException
	{
		Scanner key = new Scanner(System.in);
		
		int sum = 0;
		
		// Gets the name of the file
		
		System.out.println("Enter file name: ");
		String filename = key.nextLine();
		
		// Checks if the file exists or not
		
		File file = new File(filename);
		
		if(!file.exists())
		{
			System.out.println("The file " + file +" is not found.");
			System.exit(0);
		}
		
		// If file exists open for reading
		 
		Scanner input = new Scanner(file);
		
		/*
			Reads until the end of file
			Sums up all the number
		*
		*/
		
		while(input.hasNext())
		{
			int number = input.nextInt();
			
			sum += number;
			
		}
		
		input.close();
		
		System.out.println("The sum of the number is " + sum);
	}
}
		

		