java - How to check if a file path is relative to another file path? -


if have path:

string path = "/some/path" 

how can check if other paths relative (given going concatenate 'anotherpath' onto 'path')?

for example:

string anotherpath = ""; // relative = true  // result in full path of "/some/path"  string anotherpath = "/some/more"; // relative = true // result in full path of "/some/path/some/more"  string anotherpath = "some/more"; // relative = true // result in full path of "/some/path/some/more"  string anotherpath = "../../trying/go/up"; // relative = false // result in invalid full path of "/trying/go/up"  string anotherpath = "../more"; // relative = true // result in full path of "/some/more" 

also, possible these checks using strings rather file or url objects? (as not able write filesystem)


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -