I am actually having 2 issues which might or might not be related to each other. I have a
Java class in /dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10/dir11/dir12
that needs to write to a file located in /dir1/dir2/dir3/dir4/dir5/dirA/dirB
So I'm starting out with:
File logFile = new File("/dir1/dir2/dir3/dir4/dir5/dirA/dirB/test.txt");
then checking the value of logFile.exists() (The file should always exist because I created it manually prior to running the program.)
If logFile.exists() == true, then I'm constructing a FileWriter and writing some stuff to the file.
First attempt gave logFile.exists() == false.
Then I moved the text file into the same directory where the Java class lives, and used
File logFile = new File("test.txt");
This gave me logFile.exists() == true, and the program was able to write to the file also. Then I started moving the text file up the tree, one level at a time. I got logFile.exists() == true all the way to one directory above the target:
File logFile = new File("/dir1/dir2/dir3/dir4/dir5/dirA/test.txt"); // still OK, logFile.exists() == true
But when I added in that last directory level (dirB) then I got logFile.exists() == false.
I also tried
File logFile = new File("../../../../../../../dirA/dirB/test.txt");
to no avail.
Any idea what I should look for about dirB that can be causing this? I checked the obvious things such as spelling of names, no levels omitted from path, etc.
My second question is about writing to the file when it is found. (I'm not even sure whether this is *really* a Java question or a UNIX question, so if it's not a Java question, somebody tell me.) When I had my text file in the same directory with the Java class, the write operation succeeded. As soon as I moved it out of there, I started getting "permission denied" even when both the file and the directory it lived in had permissions set for the whole world to be able to write as well as read. I am wondering whether Java ever says "permission denied" for other reasons besides what *I* would recognize as permissions being set wrong in the OS? Here's code:
Thanks in advance.
[ March 26, 2004: Message edited by: Paula Davis ]