如果我的问题正确,那么您可以执行以下操作:
File a = new File("/some/abs/path");File parentFolder = new File(a.getParent());File b = new File(parentFolder, "../some/relative/path");String absolute = b.getCanonicalPath(); // may throw IOException
如果我的问题正确,那么您可以执行以下操作:
File a = new File("/some/abs/path");File parentFolder = new File(a.getParent());File b = new File(parentFolder, "../some/relative/path");String absolute = b.getCanonicalPath(); // may throw IOException