You are mistaking instantiating an instance of class File with actually writing a temp file to Disk. Take this line.
You are mistaking instantiating an instance of class File with actually writing a temp file to Disk. Take this line Scanner diskScanner = new Scanner(new File("EmployeeInfo. Txt")); And replace it with this File newFile = File.
CreateTempFile("EmployeeInfo", ". Txt"); Scanner diskScanner = new Scanner(newFile); Edit: Peter makes a good point. I'm face palming right now.
You know it won't have anything in it. – Peter Lawrey Mar 24 at 15:43.
It will create a new file when you write to it. However to read from it, it must already exist. You might like to check it exists with File file = new File("EmployeeInfo.
Txt"); if (file.exists()) { Scanner diskScanner = new Scanner(file); for (int empNum = 1; empNum.
The File object can't find the filename you've passed. You either need to pass the full path of EmployeeInfo. Txt to new File(...) or make sure current working directory is the directory that contains this file.
The File constructor does not create a file. Rather, it creates the information in Java needed to access a file on disk. You'd have to actually do file IO in Java using the created File for a new file to be created.
The Scanner constructor requires an existing File. So you need a full path to the real, valid location of EmployeeInfo. Txt or to create that file using File I/O first.
This tutorial on I/O in Java will help.
You thought wrong :D A Scanner needs a existing file, which seems quite logical as it reads values and without a existing file its difficult to read. The documentation also states that: Throws: FileNotFoundException - if source is not found So, in short: You must provide a readable, existing file to a scanner.
As the other answer explain, the file is not created just by using new File("EmployeeInfo. Txt"). You can check is the file exists using File file = new File("EmployeeInfo.
Txt"); if(file.exists()) { //it exists } or you can create the file (if it doesn't exists yet) using file.createNewFile(); that method returns true if the file was created and false if it already existed.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.