Results 1 to 2 of 2
-
Static function to get current working directory
The following static function can be used to get the current working director.
Java Code:private static void doGetDir() { String curDir = System.getProperty("user.dir"); System.out.println("\nThe current working directory is:"); System.out.println(" - " + curDir); }
- 06-23-2008, 02:13 AM #2
Uh,.. user home dir is cur dir?
Only reading the code once, it appears to me to be getting user home directory. To get current dir would we not:
And, as well, working dir and current dir may be somewhat misleading for inexperienced coders. Say runnable Java code with a properly written main() and so on is in /dir/dir/program.class and the code does File fidelus = new File("../dir/dir/drivel.dat"); or opens several files or tries to do some beginner blunder or ..... ( unthought of work goes here )Java Code:String currentDir = new File(".");
Where did the concept of working dir go?....perhaps concept of working directory is of limited scope. If os supports multiple file handles open, concept of working directory is archaic.
Similar Threads
-
How to get Current Directory through File
By Java Tip in forum java.ioReplies: 0Last Post: 04-05-2008, 10:14 AM -
Static methods - not working
By Echilon in forum New To JavaReplies: 2Last Post: 12-21-2007, 01:31 PM -
Error: Non-static method append(char) cannot be referenced from a static context
By paul in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 05:05 AM -
How to get the current working directory in EJB?
By sathish_2111 in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 07-19-2007, 04:24 PM -
How can i get current directory?
By Ashley in forum New To JavaReplies: 1Last Post: 05-26-2007, 01:21 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks