PathUtil { public static File file( File file ) { if ( file == null ) { return null; } try { return file.getCanonicalFile(); } catch ( IOException e ) { return file.getAbsoluteFile(); } } private  PathUtil(); static boolean existAll( File... files ); static boolean existAll( List<String> paths ); static boolean existAny( File... files ); static File[] existingFiles( Collection<String> paths ); static File[] existingFiles( File... files ); static List<File> existingFilesList( Collection<String> paths ); static List<File> existingFilesList( List<File> files ); static File file( File file ); static File file( String path ); static File file( String path, File basedir ); static File file( String path, File... basedirs ); static File file( String path, List<File> basedirs ); static File file( String path, String basedir ); static String fileExtention( File file ); static File[] files( Collection<String> paths ); static Collection<File> files( List<String> paths, File basedir ); static File[] files( String... paths ); static Collection<File> files( String[] paths, File basedir ); static File[] files( String[] paths, List<File> basedirs ); static List<File> filesList( Collection<String> paths ); static String path( File file ); static String[] paths( Collection<File> files ); static String[] paths( File... files ); static List<String> pathsList( File[] files ); static List<String> pathsList( List<File> files ); static String pathString( File[] files ); static String relativePath( File home, File f );  }
@Test public void testGetFile() throws IOException { assertThat( PathUtil.file( (String) null ), nullValue() ); assertThat( PathUtil.file( _PATH ), equalTo( new File( _PATH ).getCanonicalFile() ) ); }
@Test public void testGetFileFile() { assertThat( PathUtil.file( (File) null ), nullValue() ); assertThat( PathUtil.file( f3 ), equalTo( f1 ) ); assertThat( PathUtil.file( f4 ), equalTo( f2 ) ); }
@Test public void testGetFileStringFile() { assertThat( PathUtil.file( null, f1 ), nullValue() ); assertThat( PathUtil.file( f5.getAbsolutePath(), f1 ), equalTo( f5 ) ); assertThat( PathUtil.file( f5.getName(), f5.getParentFile() ), equalTo( f5 ) ); }
@Test public void testGetFileStringFileArray() { assertThat( PathUtil.file( null, f5, f1 ), nullValue() ); assertThat( PathUtil.file( f5.getName(), f5.getParentFile(), f1 ), equalTo( f5 ) ); assertThat( PathUtil.file( f5.getAbsolutePath(), f1, f1 ), equalTo( f5 ) ); }
@Test public void testGetFileStringListOfFile() { assertThat( PathUtil.file( null, Collections.singletonList( f5 ) ), nullValue() ); assertThat( PathUtil.file( f5.getName(), Collections.singletonList( f5.getParentFile() ) ), equalTo( f5 ) ); assertThat( PathUtil.file( f5.getAbsolutePath(), Collections.singletonList( f1 ) ), equalTo( f5 ) ); assertThat( PathUtil.file( f5.getName(), new ArrayList<File>() ), nullValue() ); }