renisenbb
asked on
Java: File not found exception
String file = "/c/Dir1/Dir2/abc.txt";
BufferedReader br = new BufferedReader(new FileReader(file));
java.io.FileNotFoundExcept ion: \c\Dir1\Dir2\abc.txt (The system cannot find the path specified)
My OS is Windows 7.
I am using cygwin, and i can see the /c/Dir1/Dir2/abc.txt (unix style)
But in Eclipse, I am getting the above error.
However, if I use
File file = new File("C:\\Dir1\\Dir2\\abc. txt");
This works fine. But is there a way for me to specify the file path in the unix style.
BufferedReader br = new BufferedReader(new FileReader(file));
java.io.FileNotFoundExcept
My OS is Windows 7.
I am using cygwin, and i can see the /c/Dir1/Dir2/abc.txt (unix style)
But in Eclipse, I am getting the above error.
However, if I use
File file = new File("C:\\Dir1\\Dir2\\abc.
This works fine. But is there a way for me to specify the file path in the unix style.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Because eventually, i want my code to work on a unix box.Well then, wouldn't you just pass the file path as a parameter to your program (or have it in a properties file, or ..... many other configurable possibilities). That way you can pass "C:\Dir1\Dir2\abc.txt" to your program when running on Windows and then pass what ever the correct unix path is when you run it on the unix box.
:)
ASKER
/c/Dir1/Dir2/abc.txt
Because eventually, i want my code to work on a unix box.