I am wondering if there is a quick simple way to check whether a file path comes under another path. For example, given C:\Fruit\Apple\Core, I want to test it against a list of files, which contains C:\Fruit\Apple, and be able to tell that it is contained within that path.
Just writing this question it occurs to me that I can simply compare the substring of the longer file against the current file.
So what I’d like to know now, is there any way to do this with File objects? Or would it still be easier to get the string version of each path and compare as above. (I am still using java 1.6 so cannot use java.nio.Path;)
string1.startsWith(string2)is still easiest.