-3

i tried to execute this code but it is not running and getting the following error "Exception in thread "main" java.io.FileNotFoundException" and i don't know how to overcome..

class Showoccupancy{
    public static void main(String args[]) throws FileNotFoundException
    {
        Scanner diskscanner = new Scanner(new File("Showoccupancy"));
        System.out.println("Room \t guests");
        for(int roomnum =0; roomnum<10; roomnum++)
        {
            System.out.print(roomnum);
            System.out.print( " \t ");
            System.out.print(diskscanner.nextInt());
        }
    }
}

can any one give solution for it?

PakkuDon
  • 1,631
  • 4
  • 21
  • 21
  • The file you specified either doesn't exist, or you gave an incorrect path to it. The exception `FileNotFoundException` is pretty straight forward. – takendarkk Jan 18 '14 at 06:41

1 Answers1

2

This simply means that the file you are looking for does not exist in the directory of the java file that is executing the code. Also, make sure you include the relevant file extension in your name, i.e. Showoccupancy.txt

Kent Hawkings
  • 2,653
  • 1
  • 22
  • 29