Very frustrating problem with writing to a file, cannot find file when overwriting.
Hi, I wrote a database program that works perfectly fine on my home computer with Java 1.7. However, when I run the same exact code on my school computer there is a problem with overwriting a text file. It says java.io.FileNotFoundException even though it works when I append the file by typing "true" after the file name. So basically it can't find the file when I want it to overwrite, but it can when I tell it to append. And I've made sure to close all previous input/output streams.
I am using this line of code for the file writer:
PrintWriter output = new PrintWriter(new FileWriter("textfile.txt"))
Could different Java versions be a problem or the fact that my school computers are on windows XP? Is there any other way to write to the file instead of the above code? I never had this problem before, thanks.
Re: Very frustrating problem with writing to a file, cannot find file when overwriting.
Try by giving the exact path
PrintWriter output = new PrintWriter(new FileWriter("C:\\textfile.txt"))