wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is the empty file descriptor a directory?
 
Similar Threads
java.io.File methods - big muddle!
mmm.. music
Strange for loop behavior
FileNotFoundException - Access is denied
Files, Iterators and ClassCastExceptions