Can a java File that isFile() also be isDirectory()?

file, java

Solution

Looking at JavaDoc, this seems to be always the case:

http://docs.oracle.com/javase/7/docs/api/java/io/File.html#isFile()

isDirectory:

true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise

isFile:

true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.

Problem

The following tests passes: ``` File aDir = new File("aDir"); assertTrue(aDir.exists()); assertTrue(aDir.isDirectory()); assertFalse(aDir.isFile()); File aFile = new File("aFile"); assertTrue(aFile.exists()); assertFalse(aFile.isDirectory()); assertTrue(aFile.isFile()); File awol = new File("notInFileSystem"); assertFalse(awol.exists()); assertFalse(awol.isDirectory()); assertFalse(awol.isFile()); ``` On the surface of things, And it seems to imply that for all files where `file.isFile()` is true, `file.isDirectory()` is false. Is there any known type of file system/file type/java platform where this assumption does not hold? (There are all sorts of wild in-betweeen categories of files (symlinks, junction points, symlinks/junction points with missing targets etc) that may behave slightly differently)

Original source