Why is directory name which contains dot(s) in the end is treated as a directory even if doesn't exists using File object in Java? -


i have directory contains several files , directories. writing small java program displays files present in directory supplied parameter.

the problem facing when append dot(s) after directory name, being treated existing if directory not present. further clarify, suppose have directory named "abc" exists. works fine when enter "abc". when enter directory name "abc...", directory being treated exists. want avoid it. creating file object using

file directory = new file( filename ); if ( directory.exists() ) {      // } 

any suggestions how can avoid it?

this unrelated java, it's windows thing: trailing dot(s) removed file , folder names. even c/c++ programs can't it.

as workaround, try use prefix \\?\:

file dir = new file( "\\\\?\\" + path ); 

but disable lot of other things relative paths , slash conversion.

related answers:


Comments