Just got one exception when I wanted to use a local file inside a local directory:
File f = new File("/data/a.xml");
FileReader r = new FileReader(f);
I got "java.io.FileNotFoundException". I used "/data/a.xml" directly because I saw some one use it the similar way. I thought I might ignore the use of "." to point to the current directory. It seems do not work. I have to add it back again. Then the code below works:
File f = new File("./data/a.xml");
FileReader r = new FileReader(f);
------------------------------------------
Then I check that guy's code again, and I found the difference. He is in fact using:
File f = new File("data/a.xml");
FileReader r = new FileReader(f);
-------------------------------------------
Now I know, I should either use dot this way: "./d1/d2/f" or "d1/d2/f" when I want to access a file f located in my current work directory. Great.
File f = new File("/data/a.xml");
FileReader r = new FileReader(f);
I got "java.io.FileNotFoundException". I used "/data/a.xml" directly because I saw some one use it the similar way. I thought I might ignore the use of "." to point to the current directory. It seems do not work. I have to add it back again. Then the code below works:
File f = new File("./data/a.xml");
FileReader r = new FileReader(f);
------------------------------------------
Then I check that guy's code again, and I found the difference. He is in fact using:
File f = new File("data/a.xml");
FileReader r = new FileReader(f);
-------------------------------------------
Now I know, I should either use dot this way: "./d1/d2/f" or "d1/d2/f" when I want to access a file f located in my current work directory. Great.