Class IOHelper


  • public final class IOHelper
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void close​(java.io.InputStream in)  
      static void close​(java.io.OutputStream out)  
      static void close​(java.lang.AutoCloseable closeable)  
      static java.net.URL convertToURL​(java.lang.String url)  
      static void copy​(java.nio.file.Path source, java.nio.file.Path target)  
      static void createParentDirs​(java.nio.file.Path path)  
      static java.lang.String decode​(byte[] bytes)  
      static java.lang.String decodeASCII​(byte[] bytes)  
      static void deleteDir​(java.nio.file.Path dir, boolean self)  
      static byte[] encode​(java.lang.String s)  
      static byte[] encodeASCII​(java.lang.String s)  
      static boolean exists​(java.nio.file.Path path)  
      static java.nio.file.Path getCodeSource​(java.lang.Class<?> clazz)  
      static java.lang.String getFileName​(java.nio.file.Path path)  
      static java.lang.String getIP​(java.net.SocketAddress address)  
      static byte[] getResourceBytes​(java.lang.String name)  
      static java.net.URL getResourceURL​(java.lang.String name)  
      static boolean hasExtension​(java.nio.file.Path file, java.lang.String extension)  
      static boolean isDir​(java.nio.file.Path path)  
      static boolean isEmpty​(java.nio.file.Path dir)  
      static boolean isFile​(java.nio.file.Path path)  
      static boolean isValidFileName​(java.lang.String fileName)  
      static boolean isValidPath​(java.lang.String path)  
      static boolean isValidTextureBounds​(int width, int height, boolean cloak)  
      static void move​(java.nio.file.Path source, java.nio.file.Path target)  
      static byte[] newBuffer()  
      static java.io.BufferedInputStream newBufferedInput​(java.net.URL url)  
      static java.io.InputStream newBufferedInput​(java.nio.file.Path file)  
      static java.io.OutputStream newBufferedOutput​(java.nio.file.Path file)  
      static java.io.OutputStream newBufferedOutput​(java.nio.file.Path file, boolean append)  
      static java.io.ByteArrayOutputStream newByteArrayOutput()  
      static char[] newCharBuffer()  
      static java.net.URLConnection newConnection​(java.net.URL url)  
      static java.net.HttpURLConnection newConnectionPost​(java.net.URL url)  
      static java.util.zip.Deflater newDeflater()  
      static java.util.zip.Inflater newInflater()  
      static java.io.InputStream newInput​(java.net.URL url)  
      static java.io.InputStream newInput​(java.nio.file.Path file)  
      static java.io.OutputStream newOutput​(java.nio.file.Path file)  
      static java.io.OutputStream newOutput​(java.nio.file.Path file, boolean append)  
      static java.io.BufferedReader newReader​(java.io.InputStream input)  
      static java.io.BufferedReader newReader​(java.io.InputStream input, java.nio.charset.Charset charset)  
      static java.io.BufferedReader newReader​(java.net.URL url)  
      static java.io.BufferedReader newReader​(java.nio.file.Path file)  
      static java.net.Socket newSocket()  
      static java.io.BufferedWriter newWriter​(java.io.FileDescriptor fd)  
      static java.io.BufferedWriter newWriter​(java.io.OutputStream output)  
      static java.io.BufferedWriter newWriter​(java.nio.file.Path file)  
      static java.io.BufferedWriter newWriter​(java.nio.file.Path file, boolean append)  
      static java.util.zip.ZipEntry newZipEntry​(java.lang.String name)  
      static java.util.zip.ZipEntry newZipEntry​(java.util.zip.ZipEntry entry)  
      static java.util.zip.ZipInputStream newZipInput​(java.io.InputStream input)  
      static java.util.zip.ZipInputStream newZipInput​(java.net.URL url)  
      static java.util.zip.ZipInputStream newZipInput​(java.nio.file.Path file)  
      static byte[] read​(java.io.InputStream input)  
      static void read​(java.io.InputStream input, byte[] bytes)  
      static byte[] read​(java.net.URL url)  
      static byte[] read​(java.nio.file.Path file)  
      static java.nio.file.attribute.BasicFileAttributes readAttributes​(java.nio.file.Path path)  
      static java.awt.image.BufferedImage readTexture​(java.lang.Object input, boolean cloak)  
      static java.lang.String request​(java.net.URL url)  
      static java.net.InetSocketAddress resolve​(java.net.InetSocketAddress address)  
      static java.nio.file.Path resolveIncremental​(java.nio.file.Path dir, java.lang.String name, java.lang.String extension)  
      static java.nio.file.Path resolveJavaBin​(java.nio.file.Path javaDir)  
      static void setSocketFlags​(java.net.Socket socket)  
      static java.nio.file.Path toAbsPath​(java.nio.file.Path path)  
      static java.lang.String toAbsPathString​(java.nio.file.Path path)  
      static byte[] toByteArray​(java.io.InputStream in)  
      static java.nio.file.Path toPath​(java.lang.String path)  
      static java.lang.String toString​(java.nio.file.Path path)  
      static java.net.URI toURI​(java.net.URL url)  
      static java.net.URL toURL​(java.nio.file.Path path)  
      static void transfer​(byte[] write, java.nio.file.Path file, boolean append)  
      static long transfer​(java.io.InputStream input, java.io.OutputStream output)  
      static long transfer​(java.io.InputStream input, java.nio.file.Path file)  
      static long transfer​(java.io.InputStream input, java.nio.file.Path file, boolean append)  
      static void transfer​(java.nio.file.Path file, java.io.OutputStream output)  
      static java.lang.String urlDecode​(java.lang.String s)  
      static java.lang.String urlEncode​(java.lang.String s)  
      static java.lang.String verifyFileName​(java.lang.String fileName)  
      static int verifyLength​(int length, int max)  
      static java.awt.image.BufferedImage verifyTexture​(java.awt.image.BufferedImage skin, boolean cloak)  
      static java.lang.String verifyURL​(java.lang.String url)  
      static void walk​(java.nio.file.Path dir, java.nio.file.FileVisitor<java.nio.file.Path> visitor, boolean hidden)  
      static void write​(java.nio.file.Path file, byte[] bytes)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UNICODE_CHARSET

        public static final java.nio.charset.Charset UNICODE_CHARSET
      • ASCII_CHARSET

        public static final java.nio.charset.Charset ASCII_CHARSET
      • SOCKET_TIMEOUT

        public static final int SOCKET_TIMEOUT
      • HTTP_TIMEOUT

        public static final int HTTP_TIMEOUT
      • BUFFER_SIZE

        public static final int BUFFER_SIZE
      • FS

        public static final java.nio.file.FileSystem FS
      • PLATFORM_SEPARATOR

        public static final java.lang.String PLATFORM_SEPARATOR
      • POSIX

        public static final boolean POSIX
      • JVM_DIR

        public static final java.nio.file.Path JVM_DIR
      • HOME_DIR

        public static final java.nio.file.Path HOME_DIR
      • WORKING_DIR

        public static final java.nio.file.Path WORKING_DIR
      • USER_AGENT

        public static final java.lang.String USER_AGENT
    • Method Detail

      • close

        public static void close​(java.lang.AutoCloseable closeable)
      • close

        public static void close​(java.io.InputStream in)
      • close

        public static void close​(java.io.OutputStream out)
      • convertToURL

        public static java.net.URL convertToURL​(java.lang.String url)
      • copy

        public static void copy​(java.nio.file.Path source,
                                java.nio.file.Path target)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • createParentDirs

        public static void createParentDirs​(java.nio.file.Path path)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • decode

        public static java.lang.String decode​(byte[] bytes)
      • decodeASCII

        public static java.lang.String decodeASCII​(byte[] bytes)
      • deleteDir

        public static void deleteDir​(java.nio.file.Path dir,
                                     boolean self)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • encode

        public static byte[] encode​(java.lang.String s)
      • encodeASCII

        public static byte[] encodeASCII​(java.lang.String s)
      • exists

        public static boolean exists​(java.nio.file.Path path)
      • getCodeSource

        public static java.nio.file.Path getCodeSource​(java.lang.Class<?> clazz)
      • getFileName

        public static java.lang.String getFileName​(java.nio.file.Path path)
      • getIP

        public static java.lang.String getIP​(java.net.SocketAddress address)
      • getResourceBytes

        public static byte[] getResourceBytes​(java.lang.String name)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • getResourceURL

        public static java.net.URL getResourceURL​(java.lang.String name)
                                           throws java.nio.file.NoSuchFileException
        Throws:
        java.nio.file.NoSuchFileException
      • hasExtension

        public static boolean hasExtension​(java.nio.file.Path file,
                                           java.lang.String extension)
      • isDir

        public static boolean isDir​(java.nio.file.Path path)
      • isEmpty

        public static boolean isEmpty​(java.nio.file.Path dir)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • isFile

        public static boolean isFile​(java.nio.file.Path path)
      • isValidFileName

        public static boolean isValidFileName​(java.lang.String fileName)
      • isValidPath

        public static boolean isValidPath​(java.lang.String path)
      • isValidTextureBounds

        public static boolean isValidTextureBounds​(int width,
                                                   int height,
                                                   boolean cloak)
      • move

        public static void move​(java.nio.file.Path source,
                                java.nio.file.Path target)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • newBuffer

        public static byte[] newBuffer()
      • newByteArrayOutput

        public static java.io.ByteArrayOutputStream newByteArrayOutput()
      • newCharBuffer

        public static char[] newCharBuffer()
      • newConnection

        public static java.net.URLConnection newConnection​(java.net.URL url)
                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • newConnectionPost

        public static java.net.HttpURLConnection newConnectionPost​(java.net.URL url)
                                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • newDeflater

        public static java.util.zip.Deflater newDeflater()
      • newInflater

        public static java.util.zip.Inflater newInflater()
      • newInput

        public static java.io.InputStream newInput​(java.nio.file.Path file)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • newBufferedInput

        public static java.io.InputStream newBufferedInput​(java.nio.file.Path file)
                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • newInput

        public static java.io.InputStream newInput​(java.net.URL url)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • newBufferedInput

        public static java.io.BufferedInputStream newBufferedInput​(java.net.URL url)
                                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • newOutput

        public static java.io.OutputStream newOutput​(java.nio.file.Path file)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • newBufferedOutput

        public static java.io.OutputStream newBufferedOutput​(java.nio.file.Path file)
                                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • newOutput

        public static java.io.OutputStream newOutput​(java.nio.file.Path file,
                                                     boolean append)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • newBufferedOutput

        public static java.io.OutputStream newBufferedOutput​(java.nio.file.Path file,
                                                             boolean append)
                                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • newReader

        public static java.io.BufferedReader newReader​(java.io.InputStream input)
      • newReader

        public static java.io.BufferedReader newReader​(java.io.InputStream input,
                                                       java.nio.charset.Charset charset)
      • newReader

        public static java.io.BufferedReader newReader​(java.nio.file.Path file)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • newReader

        public static java.io.BufferedReader newReader​(java.net.URL url)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • newSocket

        public static java.net.Socket newSocket()
                                         throws java.net.SocketException
        Throws:
        java.net.SocketException
      • newWriter

        public static java.io.BufferedWriter newWriter​(java.io.FileDescriptor fd)
      • newWriter

        public static java.io.BufferedWriter newWriter​(java.io.OutputStream output)
      • newWriter

        public static java.io.BufferedWriter newWriter​(java.nio.file.Path file)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • newWriter

        public static java.io.BufferedWriter newWriter​(java.nio.file.Path file,
                                                       boolean append)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • newZipEntry

        public static java.util.zip.ZipEntry newZipEntry​(java.lang.String name)
      • newZipEntry

        public static java.util.zip.ZipEntry newZipEntry​(java.util.zip.ZipEntry entry)
      • newZipInput

        public static java.util.zip.ZipInputStream newZipInput​(java.io.InputStream input)
      • newZipInput

        public static java.util.zip.ZipInputStream newZipInput​(java.nio.file.Path file)
                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • newZipInput

        public static java.util.zip.ZipInputStream newZipInput​(java.net.URL url)
                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public static byte[] read​(java.io.InputStream input)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public static void read​(java.io.InputStream input,
                                byte[] bytes)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public static byte[] read​(java.nio.file.Path file)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public static byte[] read​(java.net.URL url)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readAttributes

        public static java.nio.file.attribute.BasicFileAttributes readAttributes​(java.nio.file.Path path)
                                                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readTexture

        public static java.awt.image.BufferedImage readTexture​(java.lang.Object input,
                                                               boolean cloak)
                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • request

        public static java.lang.String request​(java.net.URL url)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • resolve

        public static java.net.InetSocketAddress resolve​(java.net.InetSocketAddress address)
      • resolveIncremental

        public static java.nio.file.Path resolveIncremental​(java.nio.file.Path dir,
                                                            java.lang.String name,
                                                            java.lang.String extension)
      • resolveJavaBin

        public static java.nio.file.Path resolveJavaBin​(java.nio.file.Path javaDir)
      • setSocketFlags

        public static void setSocketFlags​(java.net.Socket socket)
                                   throws java.net.SocketException
        Throws:
        java.net.SocketException
      • toAbsPathString

        public static java.lang.String toAbsPathString​(java.nio.file.Path path)
      • toAbsPath

        public static java.nio.file.Path toAbsPath​(java.nio.file.Path path)
      • toByteArray

        public static byte[] toByteArray​(java.io.InputStream in)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • toPath

        public static java.nio.file.Path toPath​(java.lang.String path)
      • toString

        public static java.lang.String toString​(java.nio.file.Path path)
      • toURI

        public static java.net.URI toURI​(java.net.URL url)
      • toURL

        public static java.net.URL toURL​(java.nio.file.Path path)
      • transfer

        public static void transfer​(byte[] write,
                                    java.nio.file.Path file,
                                    boolean append)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • transfer

        public static long transfer​(java.io.InputStream input,
                                    java.io.OutputStream output)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • transfer

        public static long transfer​(java.io.InputStream input,
                                    java.nio.file.Path file)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • transfer

        public static long transfer​(java.io.InputStream input,
                                    java.nio.file.Path file,
                                    boolean append)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • transfer

        public static void transfer​(java.nio.file.Path file,
                                    java.io.OutputStream output)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • urlDecode

        public static java.lang.String urlDecode​(java.lang.String s)
      • urlEncode

        public static java.lang.String urlEncode​(java.lang.String s)
      • verifyFileName

        public static java.lang.String verifyFileName​(java.lang.String fileName)
      • verifyLength

        public static int verifyLength​(int length,
                                       int max)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • verifyTexture

        public static java.awt.image.BufferedImage verifyTexture​(java.awt.image.BufferedImage skin,
                                                                 boolean cloak)
      • verifyURL

        public static java.lang.String verifyURL​(java.lang.String url)
      • walk

        public static void walk​(java.nio.file.Path dir,
                                java.nio.file.FileVisitor<java.nio.file.Path> visitor,
                                boolean hidden)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public static void write​(java.nio.file.Path file,
                                 byte[] bytes)
                          throws java.io.IOException
        Throws:
        java.io.IOException