Consider two given file paths as strings:
/path/to/dir and /path/to/dir/file
In Java, how can one test, if the later file path would represent a real file on disk, which is below or equal the directory represented by the first string. Here are some more examples to clarify this point, including some sample return values of a checking function that is questioned here:
/path/to/dir /path/to/dir (true)
/path/to/dir /path/to/dir/file (true)
/path/to/dir /path (false)
/path/to/dir /path/to/dir/../../file (false)
/path/to/dir file (false)
/path/to/dir /path/to/dir/dir2/../ (true)
Would one get rid of the dots by the File method .getCanonicalPath and then check on a string level? Maybe there is a better way. I could not find out, what File's .compareTo does exactly.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)