I want to check if this String is a file or a directory, I tried the isFile () and isDirectory () File methods, but the problem is that if the directory or file does not exist, these methods return false, because, as stated in javadoc:
isFile () :
true if and only if there is a file indicated by this abstract path name and is a normal file; false otherwise
isDirectory () :
true if and only if there is a file indicated by this abstract path name and is a directory; false otherwise
Basically, I need two methods without an exist clause ...
So, I want to check whether a given line matches the directory format or matches the file format in a multi-platform context (therefore it should work on Windows, Linux and Mac Os X).
Is there any library that provides these methods? What could be the best implementation of these methods?
UPDATE
In the case of a line, which may be like (without extension) by default, it should be identified as a directory if a file with this path does not exist.
source share