@Test public void testSafeResolution() throws Exception { Path cwd = Paths.get("."); String windows = "C:/temp/file.txt"; String linux = "/root/dir/file.txt"; boolean ex = false; try { FSUtil.resolveRelative(cwd, windows); } catch (IllegalArgumentException e) { ex = true; } try { FSUtil.resolveRelative(cwd, linux); } catch (IllegalArgumentException e) { ex = true; } assertTrue("IllegalArgumentException should have been thrown", ex); }
public static Path resolveRelative(Path p, String other) { Path op = Paths.get(other); if (op.isAbsolute()) { throw new IllegalArgumentException(other + " cannot be an absolute path!"); } return p.resolve(op); }
FSUtil { public static Path resolveRelative(Path p, String other) { Path op = Paths.get(other); if (op.isAbsolute()) { throw new IllegalArgumentException(other + " cannot be an absolute path!"); } return p.resolve(op); } }
FSUtil { public static Path resolveRelative(Path p, String other) { Path op = Paths.get(other); if (op.isAbsolute()) { throw new IllegalArgumentException(other + " cannot be an absolute path!"); } return p.resolve(op); }  }
FSUtil { public static Path resolveRelative(Path p, String other) { Path op = Paths.get(other); if (op.isAbsolute()) { throw new IllegalArgumentException(other + " cannot be an absolute path!"); } return p.resolve(op); }  @Deprecated static boolean checkThisIsAncestorOfThat(File ancestor, File child); @Deprecated static boolean checkThisIsAncestorOfOrSameAsThat(File ancestor, File child); @Deprecated static File getOutputFile(File outputRoot, String initialRelativePath,
                                     HANDLE_EXISTING handleExisting, String suffix); static Path getOutputPath(Path outputRoot, String initialRelativePath,
                                     HANDLE_EXISTING handleExisting, String suffix); static Path resolveRelative(Path p, String other); }
FSUtil { public static Path resolveRelative(Path p, String other) { Path op = Paths.get(other); if (op.isAbsolute()) { throw new IllegalArgumentException(other + " cannot be an absolute path!"); } return p.resolve(op); }  @Deprecated static boolean checkThisIsAncestorOfThat(File ancestor, File child); @Deprecated static boolean checkThisIsAncestorOfOrSameAsThat(File ancestor, File child); @Deprecated static File getOutputFile(File outputRoot, String initialRelativePath,
                                     HANDLE_EXISTING handleExisting, String suffix); static Path getOutputPath(Path outputRoot, String initialRelativePath,
                                     HANDLE_EXISTING handleExisting, String suffix); static Path resolveRelative(Path p, String other);  }