Mercurial Hosting > luan
view src/goodjava/io/IoUtils.java @ 1507:c8f4867fd083
remove unused file
author | Vadim Filimonov <fffilimonov@yandex.ru> |
---|---|
date | Sat, 16 May 2020 12:33:41 +0300 |
parents | d80395468b4e |
children | 86c5e7000ecf |
line wrap: on
line source
package goodjava.io; import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.nio.file.Files; import java.security.Security; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLServerSocketFactory; public final class IoUtils { private IoUtils() {} // never public static void move( File from, File to ) throws IOException { Files.move( from.toPath(), to.toPath() ); } public static void delete(File file) throws IOException { Files.deleteIfExists( file.toPath() ); } public static void mkdirs(File file) throws IOException { Files.createDirectories( 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); } public static void link(File existing,File link) throws IOException { Files.createLink( link.toPath(), existing.toPath() ); } public static void symlink(File existing,File link) throws IOException { Files.createSymbolicLink( link.toPath(), existing.toPath() ); } public static void copyAll(InputStream in,OutputStream out) throws IOException { byte[] a = new byte[8192]; int n; while( (n=in.read(a)) != -1 ) { out.write(a,0,n); } in.close(); } static { // undo restrictions of modern scum Security.setProperty("jdk.tls.disabledAlgorithms","SSLv3, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC"); } public static SSLSocketFactory getSSLSocketFactory() { return (SSLSocketFactory)SSLSocketFactory.getDefault(); } public static SSLServerSocketFactory getSSLServerSocketFactory() { return (SSLServerSocketFactory)SSLServerSocketFactory.getDefault(); } }