如果我有路径:
String path = "/some/path"
如何检查其他路径是否与其相关(鉴于我要将'anotherPath'连接到'path')?
例如:
String anotherPath = ""; // relative = true
// will result in a full path of "/some/path"
String anotherPath = "/some/more"; // relative = true
// will result in a full path of "/some/path/some/more"
String anotherPath = "some/more"; // relative = true
// will result in a full path of "/some/path/some/more"
String anotherPath = "../../trying/go/up"; // relative = false
// would result in an INVALID full path of "/trying/go/up"
String anotherPath = "../more"; // relative = true
// will result in a full path of "/some/more"
此外,是否可以仅使用字符串而不是文件或URL对象进行这些检查? (因为我无法写入文件系统)