My java program keeps thinking that every new file is not a file but a folder.
I have been bug hunting and now it will not let me save a file using FileWriter
. If I create a new File, and then check if it is a file or a directory, it says it is a directory.
I originally had a long path that was created, so I got rid of that. I also used to have the writing done in a separate thread, and got rid of that as well, but still the problem persists.
If I create a new class, with just a simple
java.io.File file = new java.io.File("test.csv");
output.print(file.isDirectory());
This comes out as true.
I can however still save graphics using javax.imageio.*
Can anyone help?
Edit: I am using eclispe 3.7.2 with java 1.7.0... File.isFile() is false, File.createNewFile() fails (java.io.FileNotFoundException (Access is Denied)). When looking in the directory I specify, there is a new folder there called test.csv. So it is creating a new folder, and is treating it as a folder, despite the fact that I am specifying it is a csv file. I have tried other file types, even no file type. But the same problem. It thinks it is a folder and not a file. This is just baffling me.
Java's new File()
does NOT create files or directories by itself. So you should show your code that does. I suspect that you have something like file.mkdirs();
somewhere - if your file
is referring to "test.csv" at this point it will create a directory called "test.csv"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With