FileNotFoundException
will either mean your file (name) doesn't exist, or the file is in the wrong location.
If you're going to read the file path as "studentdata.txt"
, what you need to understand is that, if working from an IDE, normally it tries to look for the file in the current working directory, which is the project root. So your file would need to be there.
You may instead just want to use the absolute path instead like C:/path/to/file.txt
In cases where the file will be an embedded resources, you may want to use MyClass.class.getResourceAsStream(fileName)
where the file would be in the class path. So you could do
InputStream is = MyClass.class.getResourceAsStream(fileName);
Scanner scanner = new Scanner(is);
Where your file would be in the same package as your class, if you're just going to use the file name as the path.
So you have some things to consider.