File.isFile() and File.isDirectory() both return false not only when the File is not the specified type, but also when the File itself does not exist on the filesystem. How can I determine whether the File represents a file or a directory when it does not exist?
File.isFile() and File.isDirectory() both return false not only when the File is not the
Share
In general, a specific path can represent both a directory and a file. Until there is either a directory or a file created at that path, the notion of it being for one or the other is invalid.
There is however a special case. If the path ends with a path separator (‘/’ on Unix-like systems, ‘\’ on Windows and maybe something completely different on other systems), then at least on Unix-like systems the path cannot be that of a file. I do not know if this is valid for all systems though.