Mercurial Hosting > luan
diff src/goodjava/io/IoUtils.java @ 1475:c7b86342857f
more IoUtils
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 18 Apr 2020 11:02:18 -0600 |
parents | 6c6ce14db6a8 |
children | af55cfad6e12 |
line wrap: on
line diff
--- a/src/goodjava/io/IoUtils.java Fri Apr 17 21:53:09 2020 -0600 +++ b/src/goodjava/io/IoUtils.java Sat Apr 18 11:02:18 2020 -0600 @@ -15,4 +15,18 @@ public static void delete(File file) throws IOException { Files.deleteIfExists( file.toPath() ); } + + public static boolean isSymbolicLink(File file) { + return Files.isSymbolicLink(file.toPath()); + } + + public static void deleteRecursively(File file) throws IOException { + if( file.isDirectory() && !isSymbolicLink(file) ) { + for( File f : file.listFiles() ) { + deleteRecursively(f); + } + } + delete(file); + } + } \ No newline at end of file