FsHelper { public static File toFile(String s) throws IOException, URISyntaxException { try { return createFileReference(createUrlFromString(s, true)); } catch (IllegalArgumentException e) { return new File(s); } }  static File toFile(String s); static File createFileReference(URL url); static File createFileReference(URL url, String charset); @Deprecated static URL createUrlFromString(String s); static URL createUrlFromString(String s, boolean backslashConvert); static FileFilter createFilter(String filterExpression, String filterImpl); static FileFilter logWarningIfRequired(FileFilter f); static File renameFile(File file, String suffix, FsWorker worker);  }
@Test public void testToFile() throws Exception { File f = FsHelper.toFile("file: assertEquals("fred", f.getName()); assertEquals("." + File.separator + "fred", f.getPath()); File f2 = FsHelper.toFile("c:/home/fred"); assertEquals("fred", f2.getName()); assertNotNull(f2.getParentFile()); File f3 = FsHelper.toFile("/home/fred"); assertEquals("fred", f3.getName()); assertNotNull(f3.getParentFile()); assertNotNull(f3.getParentFile().getParentFile()); assertNull(f3.getParentFile().getParentFile().getParentFile()); File f4 = FsHelper.toFile("build.gradle"); assertEquals("build.gradle", f4.getName()); assertNotNull(f4.getParentFile()); assertNull(f4.getParentFile().getParentFile()); File f5 = FsHelper.toFile("./build.gradle"); assertEquals("build.gradle", f4.getName()); assertNotNull(f4.getParentFile()); assertNull(f4.getParentFile().getParentFile()); }
@Test public void testRelativeURL() throws Exception { File f = FsHelper.toFile("file: assertEquals("fred", f.getName()); assertEquals("." + File.separator + "fred", f.getPath()); }