public final class IOUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
IOUtil.LoadJob |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CHARSET_NAME_OPTION |
static java.lang.String |
CHARSET_OPTION |
static java.nio.file.DirectoryStream.Filter<java.nio.file.Path> |
directoryFilter |
static java.lang.String |
ENCODING_OPTION |
static java.nio.file.DirectoryStream.Filter<java.nio.file.Path> |
fileFilter |
static java.nio.file.DirectoryStream.Filter<java.nio.file.Path> |
jarFilter |
static java.nio.charset.Charset |
UTF8_CHARSET |
static java.lang.String |
UTF8_ENCODING |
Modifier and Type | Method and Description |
---|---|
static boolean |
canFree(Loadable loadable) |
static void |
cleanDirectory(java.nio.file.Path root) |
static void |
close(java.io.Closeable closeable) |
static void |
copyStream(java.io.InputStream in,
java.io.OutputStream out) |
static void |
copyStream(java.io.InputStream in,
java.io.OutputStream out,
int bufferSize) |
static void |
deleteDirectory(java.nio.file.Path root) |
static boolean |
doLoad(java.lang.Object owner,
Loadable loadable) |
static java.net.URL |
encodeURL(java.net.URL source)
Creates a new
URL that points to the same resource as the source
argument, but has all its file parts properly encoded. |
static void |
ensureFolder(java.nio.file.Path path) |
static java.net.URL |
fileToUrl(java.nio.file.Path p)
Utility method to convert a
Path object to a local URL. |
static java.nio.charset.Charset |
getCharset(Options options) |
static java.nio.charset.Charset |
getCharset(Options options,
java.nio.charset.Charset defaultCharset) |
static java.io.BufferedReader |
getReader(java.io.InputStream is,
java.nio.charset.Charset cs) |
static boolean |
hasHost(java.net.URL url) |
static boolean |
isGZipSource(java.nio.file.Path path) |
static boolean |
isGZipSource(java.lang.String name) |
static boolean |
isJarResourceExists(java.net.URL url)
Checks if resource jar exist and can be opened.
|
static boolean |
isLocal(java.net.URL url) |
static boolean |
isLocalFile(java.net.URL url) |
static boolean |
isResourceExists(java.net.URL url)
Checks if resource exist and can be opened.
|
static boolean |
isUrlResourceExists(java.net.URL url)
Checks if resource URL exist and can be opened.
|
static boolean |
isZipSource(java.lang.String name) |
static int |
readInt(java.io.InputStream in) |
static long |
readLong(java.io.InputStream in) |
static java.lang.String |
readStream(java.io.InputStream input) |
static java.lang.String |
readStream(java.io.InputStream input,
java.lang.String encoding) |
static java.lang.String |
readStreamUnchecked(java.io.InputStream input) |
static java.lang.String |
readStreamUnchecked(java.io.InputStream input,
java.lang.String encoding) |
static java.lang.String |
stripJarContext(java.lang.String context) |
static java.nio.file.Path |
toRelativePath(java.nio.file.Path p) |
static void |
writeInt(java.io.OutputStream out,
int v) |
void |
writeLong(java.io.OutputStream out,
long v) |
public static final java.lang.String UTF8_ENCODING
public static final java.nio.file.DirectoryStream.Filter<java.nio.file.Path> fileFilter
public static final java.nio.file.DirectoryStream.Filter<java.nio.file.Path> jarFilter
public static final java.nio.file.DirectoryStream.Filter<java.nio.file.Path> directoryFilter
public static final java.nio.charset.Charset UTF8_CHARSET
public static final java.lang.String CHARSET_OPTION
public static final java.lang.String CHARSET_NAME_OPTION
public static final java.lang.String ENCODING_OPTION
public static void ensureFolder(java.nio.file.Path path)
public static void deleteDirectory(java.nio.file.Path root) throws java.io.IOException
java.io.IOException
public static void cleanDirectory(java.nio.file.Path root) throws java.io.IOException
java.io.IOException
public static boolean isZipSource(java.lang.String name)
public static boolean isGZipSource(java.lang.String name)
public static boolean isGZipSource(java.nio.file.Path path)
public static java.lang.String readStream(java.io.InputStream input) throws java.io.IOException
java.io.IOException
public static java.lang.String readStream(java.io.InputStream input, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public static java.lang.String readStreamUnchecked(java.io.InputStream input)
public static java.lang.String readStreamUnchecked(java.io.InputStream input, java.lang.String encoding)
public static void copyStream(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
java.io.IOException
public static void copyStream(java.io.InputStream in, java.io.OutputStream out, int bufferSize) throws java.io.IOException
java.io.IOException
public static void writeInt(java.io.OutputStream out, int v) throws java.io.IOException
java.io.IOException
RandomAccessFile.writeInt(int)
public final void writeLong(java.io.OutputStream out, long v) throws java.io.IOException
java.io.IOException
RandomAccessFile.writeLong(long)
public static int readInt(java.io.InputStream in) throws java.io.IOException
java.io.IOException
RandomAccessFile.readInt()
public static long readLong(java.io.InputStream in) throws java.io.IOException
java.io.IOException
RandomAccessFile.readLong()
public static void close(java.io.Closeable closeable)
public static boolean isLocalFile(java.net.URL url)
public static java.lang.String stripJarContext(java.lang.String context)
public static boolean hasHost(java.net.URL url)
public static boolean isLocal(java.net.URL url)
public static java.io.BufferedReader getReader(java.io.InputStream is, java.nio.charset.Charset cs) throws java.io.IOException
java.io.IOException
public static java.nio.charset.Charset getCharset(Options options, java.nio.charset.Charset defaultCharset)
public static java.nio.charset.Charset getCharset(Options options)
public static boolean isResourceExists(java.net.URL url)
url
- absolute URL which points to a resource to be checkedtrue
if given URL points to an existing resourcepublic static boolean isUrlResourceExists(java.net.URL url)
url
- absolute URL which points to a resource to be checkedtrue
if given URL points to an existing resourcepublic static boolean isJarResourceExists(java.net.URL url)
url
- absolute URL which points to a jar resource to be checkedtrue
if given URL points to an existing resourcepublic static java.net.URL fileToUrl(java.nio.file.Path p) throws java.net.MalformedURLException
Path
object to a local URL.p
- a file objectjava.net.MalformedURLException
- if file can't be represented as URL for
some reasonpublic static java.net.URL encodeURL(java.net.URL source) throws java.net.MalformedURLException
URL
that points to the same resource as the source
argument, but has all its file parts properly encoded. Note that this method will yield
undesired results if a part of the given URL
's file section has already been
encoded!java.net.MalformedURLException
public static java.nio.file.Path toRelativePath(java.nio.file.Path p)
public static boolean canFree(Loadable loadable)
public static boolean doLoad(java.lang.Object owner, Loadable loadable) throws java.lang.Exception
java.lang.Exception