This will be a really dumb question, but i can't seem to create a new file in java to save my life.
It always throws
java.io.FileNotFoundException: Users/username/Documents/testProject/test.txt (No such file or directory)
I have tried like this:
File newFile = new File("Users/username/Documents/testProject/test.txt");
and tried this:
File newFile = new File("/Users/username/Documents/testProject/test.txt");
What am i doing wrong?
Edit: apparently the issue wasn't there. I was trying to read from an empty file later on in the code, sorry folks.
ls /Users/username/Documents/testProject/test.txtfrom the terminal ? Also its not clear what you are trying to do after you create theFileobject.Fileconstructor does not throw this exception. What are you really doing?new File("...")only creates a reference to a file path; in order to create a file, you would either write to it, or use.createNewFile()