Package pro.gravit.utils.helper
Class IOHelper
- java.lang.Object
-
- pro.gravit.utils.helper.IOHelper
-
public final class IOHelper extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.charset.CharsetASCII_CHARSETstatic intBUFFER_SIZEstatic java.lang.StringCROSS_SEPARATORstatic java.nio.file.FileSystemFSstatic java.nio.file.PathHOME_DIRstatic intHTTP_TIMEOUTstatic java.nio.file.PathJVM_DIRstatic intMAX_BATCH_SIZEstatic longMB32static java.lang.StringPLATFORM_SEPARATORstatic booleanPOSIXstatic intSOCKET_TIMEOUTstatic java.nio.charset.CharsetUNICODE_CHARSETstatic java.lang.StringUSER_AGENTstatic java.nio.file.PathWORKING_DIR
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose(java.io.InputStream in)static voidclose(java.io.OutputStream out)static voidclose(java.lang.AutoCloseable closeable)static java.net.URLconvertToURL(java.lang.String url)static voidcopy(java.nio.file.Path source, java.nio.file.Path target)static voidcreateParentDirs(java.nio.file.Path path)static java.lang.Stringdecode(byte[] bytes)static java.lang.StringdecodeASCII(byte[] bytes)static voiddeleteDir(java.nio.file.Path dir, boolean self)static byte[]encode(java.lang.String s)static byte[]encodeASCII(java.lang.String s)static booleanexists(java.nio.file.Path path)static java.nio.file.PathgetCodeSource(java.lang.Class<?> clazz)static java.lang.StringgetFileName(java.nio.file.Path path)static java.lang.StringgetIP(java.net.SocketAddress address)static byte[]getResourceBytes(java.lang.String name)static java.net.URLgetResourceURL(java.lang.String name)static booleanhasExtension(java.nio.file.Path file, java.lang.String extension)static booleanisDir(java.nio.file.Path path)static booleanisEmpty(java.nio.file.Path dir)static booleanisFile(java.nio.file.Path path)static booleanisValidFileName(java.lang.String fileName)static booleanisValidPath(java.lang.String path)static booleanisValidTextureBounds(int width, int height, boolean cloak)static voidmove(java.nio.file.Path source, java.nio.file.Path target)static byte[]newBuffer()static java.io.BufferedInputStreamnewBufferedInput(java.net.URL url)static java.io.InputStreamnewBufferedInput(java.nio.file.Path file)static java.io.OutputStreamnewBufferedOutput(java.nio.file.Path file)static java.io.OutputStreamnewBufferedOutput(java.nio.file.Path file, boolean append)static java.io.ByteArrayOutputStreamnewByteArrayOutput()static char[]newCharBuffer()static java.net.URLConnectionnewConnection(java.net.URL url)static java.net.HttpURLConnectionnewConnectionPost(java.net.URL url)static java.util.zip.DeflaternewDeflater()static java.util.zip.InflaternewInflater()static java.io.InputStreamnewInput(java.net.URL url)static java.io.InputStreamnewInput(java.nio.file.Path file)static java.io.OutputStreamnewOutput(java.nio.file.Path file)static java.io.OutputStreamnewOutput(java.nio.file.Path file, boolean append)static java.io.BufferedReadernewReader(java.io.InputStream input)static java.io.BufferedReadernewReader(java.io.InputStream input, java.nio.charset.Charset charset)static java.io.BufferedReadernewReader(java.net.URL url)static java.io.BufferedReadernewReader(java.nio.file.Path file)static java.net.SocketnewSocket()static java.io.BufferedWriternewWriter(java.io.FileDescriptor fd)static java.io.BufferedWriternewWriter(java.io.OutputStream output)static java.io.BufferedWriternewWriter(java.nio.file.Path file)static java.io.BufferedWriternewWriter(java.nio.file.Path file, boolean append)static java.util.zip.ZipEntrynewZipEntry(java.lang.String name)static java.util.zip.ZipEntrynewZipEntry(java.util.zip.ZipEntry entry)static java.util.zip.ZipInputStreamnewZipInput(java.io.InputStream input)static java.util.zip.ZipInputStreamnewZipInput(java.net.URL url)static java.util.zip.ZipInputStreamnewZipInput(java.nio.file.Path file)static byte[]read(java.io.InputStream input)static voidread(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.BasicFileAttributesreadAttributes(java.nio.file.Path path)static java.awt.image.BufferedImagereadTexture(java.lang.Object input, boolean cloak)static java.lang.Stringrequest(java.net.URL url)static java.net.InetSocketAddressresolve(java.net.InetSocketAddress address)static java.nio.file.PathresolveIncremental(java.nio.file.Path dir, java.lang.String name, java.lang.String extension)static java.nio.file.PathresolveJavaBin(java.nio.file.Path javaDir)static voidsetSocketFlags(java.net.Socket socket)static java.nio.file.PathtoAbsPath(java.nio.file.Path path)static java.lang.StringtoAbsPathString(java.nio.file.Path path)static byte[]toByteArray(java.io.InputStream in)static java.nio.file.PathtoPath(java.lang.String path)static java.lang.StringtoString(java.nio.file.Path path)static java.net.URItoURI(java.net.URL url)static java.net.URLtoURL(java.nio.file.Path path)static voidtransfer(byte[] write, java.nio.file.Path file, boolean append)static longtransfer(java.io.InputStream input, java.io.OutputStream output)static longtransfer(java.io.InputStream input, java.nio.file.Path file)static longtransfer(java.io.InputStream input, java.nio.file.Path file, boolean append)static voidtransfer(java.nio.file.Path file, java.io.OutputStream output)static java.lang.StringurlDecode(java.lang.String s)static java.lang.StringurlEncode(java.lang.String s)static java.lang.StringverifyFileName(java.lang.String fileName)static intverifyLength(int length, int max)static java.awt.image.BufferedImageverifyTexture(java.awt.image.BufferedImage skin, boolean cloak)static java.lang.StringverifyURL(java.lang.String url)static voidwalk(java.nio.file.Path dir, java.nio.file.FileVisitor<java.nio.file.Path> visitor, boolean hidden)static voidwrite(java.nio.file.Path file, byte[] bytes)
-
-
-
Field Detail
-
MB32
public static final long MB32
- See Also:
- Constant Field Values
-
UNICODE_CHARSET
public static final java.nio.charset.Charset UNICODE_CHARSET
-
ASCII_CHARSET
public static final java.nio.charset.Charset ASCII_CHARSET
-
MAX_BATCH_SIZE
public static final int MAX_BATCH_SIZE
- See Also:
- Constant Field Values
-
SOCKET_TIMEOUT
public static final int SOCKET_TIMEOUT
-
HTTP_TIMEOUT
public static final int HTTP_TIMEOUT
-
BUFFER_SIZE
public static final int BUFFER_SIZE
-
CROSS_SEPARATOR
public static final java.lang.String CROSS_SEPARATOR
- See Also:
- Constant Field Values
-
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
-
-