This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Is the empty file descriptor a directory? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is the empty file descriptor a directory?" Watch "Is the empty file descriptor a directory?" New topic
Author

Is the empty file descriptor a directory?

Warren Dew
blacksmith
Ranch Hand

Joined: Mar 04, 2004
Posts: 1332
    
    2
I'm getting some behavior from java.io.File that seems to me strange:



So does the empty file descriptor (File("")) represent the current working directory, or not? What am I missing?

[edited to correct "directory" to "file" in the last line of code]
[ November 19, 2004: Message edited by: Warren Dew ]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Warren Dew:
I'm getting some behavior from java.io.File that seems to me strange:



So does the empty file descriptor (File("")) represent the current working directory, or not? What am I missing?

I'm a little confused by your code. In the last line, I see a variable named directory. However, you didn't post it's declaration or initialization.

I suspect that the first few lines of code are referencing a file named "" in the current working directory. Since the file has a blank name, you don't see it when you print out the absolute path. To get just the current working directory, you should use ".". Most modern operating systems use this convention.


Java API Documentation
The Java Tutorial
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Is the empty file descriptor a directory?