Package aQute.lib.io
Class IO
- java.lang.Object
-
- aQute.lib.io.IO
-
public class IO extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classIO.AppendableWriterAdapter(package private) static classIO.EnvironmentCalculator
-
Field Summary
Fields Modifier and Type Field Description private static intBUFFER_SIZEprivate static intDIRECT_MAP_THRESHOLDstatic java.io.Filehomeprivate static booleanisWindowsstatic java.io.FileJAVA_HOMEstatic java.io.OutputStreamnullStreamstatic java.io.WriternullWriterprivate static java.util.EnumSet<java.nio.file.StandardOpenOption>readOptionsprivate static java.util.regex.PatternRESERVED_WINDOWS_Pprivate static java.util.regex.PatternWINDOWS_MACROSstatic java.io.Fileworkprivate static java.util.EnumSet<java.nio.file.StandardOpenOption>writeOptions
-
Constructor Summary
Constructors Constructor Description IO()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringabsolutePath(java.io.File file)static java.lang.StringabsolutePath(java.nio.file.Path path)static java.io.WriterappendableToWriter(java.lang.Appendable appendable)static java.lang.Throwableclose(java.io.Closeable in)static java.lang.Throwableclose(java.lang.AutoCloseable in)static booleancloseAll(java.lang.Object... toBeClosed)Will iterate over the given toBeClose and silently close any object that implements AutoCloseable.static java.lang.Stringcollect(java.io.File file)static java.lang.Stringcollect(java.io.File file, java.lang.String encoding)static java.lang.Stringcollect(java.io.File file, java.nio.charset.Charset encoding)static java.lang.Stringcollect(java.io.InputStream in)static java.lang.Stringcollect(java.io.InputStream in, java.lang.String encoding)static java.lang.Stringcollect(java.io.InputStream in, java.nio.charset.Charset encoding)static java.lang.Stringcollect(java.io.Reader r)static java.lang.Stringcollect(java.lang.String path)static java.lang.Stringcollect(java.net.URL url)static java.lang.Stringcollect(java.net.URL url, java.lang.String encoding)static java.lang.Stringcollect(java.net.URL url, java.nio.charset.Charset encoding)static java.lang.Stringcollect(java.nio.ByteBuffer bb, java.nio.charset.Charset encoding)static java.lang.Stringcollect(java.nio.file.Path path)static java.lang.Stringcollect(java.nio.file.Path path, java.nio.charset.Charset encoding)static java.io.Filecopy(byte[] data, java.io.File file)static java.io.OutputStreamcopy(byte[] data, java.io.OutputStream out)static java.io.Writercopy(byte[] data, java.io.Writer w)static java.nio.file.Pathcopy(byte[] data, java.nio.file.Path path)static java.io.Filecopy(java.io.File src, java.io.File tgt)static java.io.OutputStreamcopy(java.io.File file, java.io.OutputStream out)static java.security.MessageDigestcopy(java.io.File file, java.security.MessageDigest md)static byte[]copy(java.io.InputStream in, byte[] data)static byte[]copy(java.io.InputStream in, byte[] data, int off, int len)static ByteBufferOutputStreamcopy(java.io.InputStream in, ByteBufferOutputStream out)static java.io.DataOutputcopy(java.io.InputStream in, java.io.DataOutput out)static java.io.Filecopy(java.io.InputStream in, java.io.File file)static java.io.OutputStreamcopy(java.io.InputStream in, java.io.OutputStream out)static java.io.OutputStreamcopy(java.io.InputStream in, java.io.OutputStream out, int limit)static java.io.Writercopy(java.io.InputStream in, java.io.Writer w)static java.io.Writercopy(java.io.InputStream in, java.io.Writer w, java.lang.String charset)static java.io.Writercopy(java.io.InputStream in, java.io.Writer w, java.nio.charset.Charset charset)static java.net.URLcopy(java.io.InputStream in, java.net.URL url)static java.net.URLcopy(java.io.InputStream in, java.net.URL url, java.lang.String method)static java.nio.ByteBuffercopy(java.io.InputStream in, java.nio.ByteBuffer bb)static java.nio.channels.WritableByteChannelcopy(java.io.InputStream in, java.nio.channels.WritableByteChannel out)static java.nio.file.Pathcopy(java.io.InputStream in, java.nio.file.Path path)static java.security.MessageDigestcopy(java.io.InputStream in, java.security.MessageDigest md)static java.io.OutputStreamcopy(java.io.Reader r, java.io.OutputStream out)static java.io.OutputStreamcopy(java.io.Reader r, java.io.OutputStream out, java.lang.String charset)static java.io.OutputStreamcopy(java.io.Reader r, java.io.OutputStream out, java.nio.charset.Charset charset)static java.io.Writercopy(java.io.Reader r, java.io.Writer w)static java.io.Filecopy(java.net.URLConnection conn, java.io.File file)static java.security.MessageDigestcopy(java.net.URLConnection conn, java.security.MessageDigest md)static java.io.Filecopy(java.net.URL url, java.io.File file)static java.security.MessageDigestcopy(java.net.URL url, java.security.MessageDigest md)static java.io.DataOutputcopy(java.nio.ByteBuffer bb, java.io.DataOutput out)static java.io.OutputStreamcopy(java.nio.ByteBuffer bb, java.io.OutputStream out)static java.io.OutputStreamcopy(java.nio.channels.ReadableByteChannel in, java.io.OutputStream out)static java.nio.channels.WritableByteChannelcopy(java.nio.channels.ReadableByteChannel in, java.nio.channels.WritableByteChannel out)static java.security.MessageDigestcopy(java.nio.channels.ReadableByteChannel in, java.security.MessageDigest md)static java.io.OutputStreamcopy(java.nio.file.Path path, java.io.OutputStream out)static java.nio.file.Pathcopy(java.nio.file.Path src, java.nio.file.Path tgt)static java.security.MessageDigestcopy(java.nio.file.Path path, java.security.MessageDigest md)static java.io.OutputStreamcopy(java.util.Collection<?> c, java.io.OutputStream out)static booleancreateSymbolicLink(java.io.File link, java.io.File target)static booleancreateSymbolicLink(java.nio.file.Path link, java.nio.file.Path target)static booleancreateSymbolicLinkOrCopy(java.io.File link, java.io.File target)Creates a symbolic link fromlinkto thetarget, or copiestargettolinkif running on Windows.static booleancreateSymbolicLinkOrCopy(java.nio.file.Path link, java.nio.file.Path target)Creates a symbolic link fromlinkto thetarget, or copiestargettolinkif running on Windows.static java.io.FilecreateTempFile(java.io.File directory, java.lang.String pattern, java.lang.String suffix)Create a temporary file.static java.nio.CharBufferdecode(java.nio.ByteBuffer bb, java.nio.charset.Charset encoding)static voiddelete(java.io.File file)Deletes the specified file.static voiddelete(java.nio.file.Path path)Deletes the specified path.static voiddeleteContent(java.io.File dir)Deletes the specified content of the given directory.static voiddeleteWithException(java.io.File file)Deletes the specified file.static voiddeleteWithException(java.nio.file.Path path)Deletes the specified path.static longdrain(java.io.InputStream in)static java.nio.ByteBufferencode(java.lang.String s, java.nio.charset.Charset encoding)static java.nio.ByteBufferencode(java.nio.CharBuffer cb, java.nio.charset.Charset encoding)static java.io.FilegetBasedFile(java.io.File base, java.lang.String file)static java.nio.file.PathgetBasedPath(java.nio.file.Path base, java.lang.String file)static java.lang.StringgetExtension(java.lang.String fileName, java.lang.String deflt)static java.io.FilegetFile(java.io.File base, java.lang.String file)static java.io.FilegetFile(java.lang.String file)static java.lang.StringgetJavaExecutablePath(java.lang.String name)static java.nio.file.PathgetPath(java.lang.String file)static java.nio.file.PathgetPath(java.nio.file.Path base, java.lang.String file)static voidinitialize(java.io.File dir)Deletes and creates directoriesstatic booleanisSymbolicLink(java.io.File link)static booleanisSymbolicLink(java.nio.file.Path link)static booleanisWindows()static java.io.Filemkdirs(java.io.File dir)static java.nio.file.Pathmkdirs(java.nio.file.Path dir)static java.lang.StringnormalizePath(java.io.File file)static java.lang.StringnormalizePath(java.lang.String path)static java.lang.StringnormalizePath(java.nio.file.Path path)static java.io.OutputStreamoutputStream(java.io.File file)static java.io.OutputStreamoutputStream(java.nio.file.Path path)static byte[]read(java.io.File file)static byte[]read(java.io.InputStream in)static byte[]read(java.net.URL url)static byte[]read(java.nio.ByteBuffer bb)static java.nio.ByteBufferread(java.nio.file.Path path)static java.nio.channels.FileChannelreadChannel(java.nio.file.Path path)static java.io.BufferedReaderreader(java.io.File file)static java.io.BufferedReaderreader(java.io.File file, java.lang.String encoding)static java.io.BufferedReaderreader(java.io.File file, java.nio.charset.Charset encoding)static java.io.BufferedReaderreader(java.io.InputStream in)static java.io.BufferedReaderreader(java.io.InputStream in, java.lang.String encoding)static java.io.BufferedReaderreader(java.io.InputStream in, java.nio.charset.Charset encoding)static java.io.BufferedReaderreader(java.lang.String s)static java.io.BufferedReaderreader(java.nio.ByteBuffer bb, java.nio.charset.Charset encoding)static java.io.BufferedReaderreader(java.nio.channels.ReadableByteChannel in, java.nio.charset.Charset encoding)static java.io.BufferedReaderreader(java.nio.CharBuffer cb)static java.io.BufferedReaderreader(java.nio.file.Path path, java.nio.charset.Charset encoding)static java.lang.StringreadUTF(java.io.DataInput in)static java.io.Filerename(java.io.File from, java.io.File to)Renamesfromtotoreplacing the target file if necessary.static java.nio.file.Pathrename(java.nio.file.Path from, java.nio.file.Path to)Renamesfromtotoreplacing the target file if necessary.static voidstore(ConsumerWithException<java.io.OutputStream> store, java.io.File target)Store output in a file but ensure that the content is updated atomically.static voidstore(java.lang.Object o, java.io.File file)static voidstore(java.lang.Object o, java.io.File file, java.lang.String encoding)static voidstore(java.lang.Object o, java.io.OutputStream out)static voidstore(java.lang.Object o, java.io.OutputStream out, java.lang.String encoding)static voidstore(java.lang.Object o, java.io.OutputStream out, java.nio.charset.Charset encoding)static voidstore(java.lang.Object o, java.io.Writer w)static voidstore(java.lang.Object o, java.nio.file.Path path, java.nio.charset.Charset encoding)static java.io.InputStreamstream(byte[] data)static java.io.InputStreamstream(java.io.File file)static java.io.InputStreamstream(java.lang.String s)static java.io.InputStreamstream(java.lang.String s, java.lang.String encoding)static java.io.InputStreamstream(java.lang.String s, java.nio.charset.Charset encoding)static java.io.InputStreamstream(java.net.URL url)static java.io.InputStreamstream(java.nio.ByteBuffer bb)static java.io.InputStreamstream(java.nio.file.Path path)static java.lang.StringtoSafeFileName(java.lang.String string)static java.net.URLtoURL(java.lang.String s, java.io.File base)private static voidtraverse(java.util.Collection<java.io.File> files, java.io.File current, Glob glob)static java.util.Collection<java.io.File>tree(java.io.File current)static java.util.Collection<java.io.File>tree(java.io.File current, java.lang.String glob)static voidwrite(byte[] data, java.io.File file)static voidwrite(byte[] data, java.io.OutputStream out)static java.nio.channels.FileChannelwriteChannel(java.nio.file.Path path)static java.io.PrintWriterwriter(java.io.File file)static java.io.PrintWriterwriter(java.io.File file, java.lang.String encoding)static java.io.PrintWriterwriter(java.io.File file, java.nio.charset.Charset encoding)static java.io.PrintWriterwriter(java.io.OutputStream out)static java.io.PrintWriterwriter(java.io.OutputStream out, java.lang.String encoding)static java.io.PrintWriterwriter(java.io.OutputStream out, java.nio.charset.Charset encoding)static java.io.PrintWriterwriter(java.nio.channels.WritableByteChannel out, java.nio.charset.Charset encoding)static java.io.PrintWriterwriter(java.nio.file.Path path)static java.io.PrintWriterwriter(java.nio.file.Path path, java.nio.charset.Charset encoding)
-
-
-
Field Detail
-
WINDOWS_MACROS
private static final java.util.regex.Pattern WINDOWS_MACROS
-
BUFFER_SIZE
private static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
DIRECT_MAP_THRESHOLD
private static final int DIRECT_MAP_THRESHOLD
- See Also:
- Constant Field Values
-
isWindows
private static final boolean isWindows
-
work
public static final java.io.File work
-
home
public static final java.io.File home
-
JAVA_HOME
public static final java.io.File JAVA_HOME
-
writeOptions
private static final java.util.EnumSet<java.nio.file.StandardOpenOption> writeOptions
-
readOptions
private static final java.util.EnumSet<java.nio.file.StandardOpenOption> readOptions
-
nullStream
public static final java.io.OutputStream nullStream
-
nullWriter
public static final java.io.Writer nullWriter
-
RESERVED_WINDOWS_P
private static final java.util.regex.Pattern RESERVED_WINDOWS_P
-
-
Method Detail
-
getExtension
public static java.lang.String getExtension(java.lang.String fileName, java.lang.String deflt)
-
tree
public static java.util.Collection<java.io.File> tree(java.io.File current)
-
tree
public static java.util.Collection<java.io.File> tree(java.io.File current, java.lang.String glob)
-
traverse
private static void traverse(java.util.Collection<java.io.File> files, java.io.File current, Glob glob)
-
copy
public static java.io.File copy(byte[] data, java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.nio.file.Path copy(byte[] data, java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.Writer copy(byte[] data, java.io.Writer w) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(byte[] data, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.Writer copy(java.io.Reader r, java.io.Writer w) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(java.io.Reader r, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(java.io.Reader r, java.io.OutputStream out, java.lang.String charset) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(java.io.Reader r, java.io.OutputStream out, java.nio.charset.Charset charset) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.Writer copy(java.io.InputStream in, java.io.Writer w) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.Writer copy(java.io.InputStream in, java.io.Writer w, java.lang.String charset) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.Writer copy(java.io.InputStream in, java.io.Writer w, java.nio.charset.Charset charset) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(java.io.InputStream in, java.io.OutputStream out, int limit) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static ByteBufferOutputStream copy(java.io.InputStream in, ByteBufferOutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
copy
public static java.io.DataOutput copy(java.io.InputStream in, java.io.DataOutput out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.nio.channels.WritableByteChannel copy(java.nio.channels.ReadableByteChannel in, java.nio.channels.WritableByteChannel out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.nio.ByteBuffer copy(java.io.InputStream in, java.nio.ByteBuffer bb) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static byte[] copy(java.io.InputStream in, byte[] data) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static byte[] copy(java.io.InputStream in, byte[] data, int off, int len) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(java.nio.ByteBuffer bb, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.DataOutput copy(java.nio.ByteBuffer bb, java.io.DataOutput out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.security.MessageDigest copy(java.net.URL url, java.security.MessageDigest md) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.security.MessageDigest copy(java.io.File file, java.security.MessageDigest md) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.security.MessageDigest copy(java.nio.file.Path path, java.security.MessageDigest md) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.security.MessageDigest copy(java.net.URLConnection conn, java.security.MessageDigest md) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.security.MessageDigest copy(java.io.InputStream in, java.security.MessageDigest md) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.security.MessageDigest copy(java.nio.channels.ReadableByteChannel in, java.security.MessageDigest md) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.File copy(java.net.URL url, java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.File copy(java.net.URLConnection conn, java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.net.URL copy(java.io.InputStream in, java.net.URL url) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.net.URL copy(java.io.InputStream in, java.net.URL url, java.lang.String method) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.File copy(java.io.File src, java.io.File tgt) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.nio.file.Path copy(java.nio.file.Path src, java.nio.file.Path tgt) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.File copy(java.io.InputStream in, java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.nio.file.Path copy(java.io.InputStream in, java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(java.io.File file, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(java.nio.file.Path path, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.nio.channels.WritableByteChannel copy(java.io.InputStream in, java.nio.channels.WritableByteChannel out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(java.nio.channels.ReadableByteChannel in, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
read
public static byte[] read(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
read
public static java.nio.ByteBuffer read(java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
read
public static byte[] read(java.nio.ByteBuffer bb)
-
read
public static byte[] read(java.net.URL url) throws java.io.IOException- Throws:
java.io.IOException
-
read
public static byte[] read(java.io.InputStream in) throws java.io.IOException- Throws:
java.io.IOException
-
write
public static void write(byte[] data, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
write
public static void write(byte[] data, java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.io.File file, java.lang.String encoding) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.io.File file, java.nio.charset.Charset encoding) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.nio.file.Path path, java.nio.charset.Charset encoding) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.nio.ByteBuffer bb, java.nio.charset.Charset encoding)
-
collect
public static java.lang.String collect(java.net.URL url, java.lang.String encoding) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.net.URL url, java.nio.charset.Charset encoding) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.net.URL url) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.lang.String path) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.io.InputStream in) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.io.InputStream in, java.lang.String encoding) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.io.InputStream in, java.nio.charset.Charset encoding) throws java.io.IOException- Throws:
java.io.IOException
-
collect
public static java.lang.String collect(java.io.Reader r) throws java.io.IOException- Throws:
java.io.IOException
-
createTempFile
public static java.io.File createTempFile(java.io.File directory, java.lang.String pattern, java.lang.String suffix) throws java.lang.IllegalArgumentException, java.io.IOExceptionCreate a temporary file.- Parameters:
directory- the directory in which to create the file. Can be null, in which case the system TMP directory is usedpattern- the filename prefix pattern. Must be at least 3 characters longsuffix- the filename suffix. Can be null, in which case (system) default suffix is used- Returns:
- temp file
- Throws:
java.lang.IllegalArgumentException- when pattern is null or too shortjava.io.IOException- when the specified (non-null) directory is not a directory
-
absolutePath
public static java.lang.String absolutePath(java.io.File file)
-
absolutePath
public static java.lang.String absolutePath(java.nio.file.Path path)
-
normalizePath
public static java.lang.String normalizePath(java.nio.file.Path path)
-
normalizePath
public static java.lang.String normalizePath(java.io.File file)
-
normalizePath
public static java.lang.String normalizePath(java.lang.String path)
-
getFile
public static java.io.File getFile(java.lang.String file)
-
getFile
public static java.io.File getFile(java.io.File base, java.lang.String file)
-
getBasedFile
public static java.io.File getBasedFile(java.io.File base, java.lang.String file) throws java.io.IOException- Throws:
java.io.IOException
-
getPath
public static java.nio.file.Path getPath(java.lang.String file)
-
getPath
public static java.nio.file.Path getPath(java.nio.file.Path base, java.lang.String file)
-
getBasedPath
public static java.nio.file.Path getBasedPath(java.nio.file.Path base, java.lang.String file) throws java.io.IOException- Throws:
java.io.IOException
-
delete
public static void delete(java.io.File file)
Deletes the specified file. Folders are recursively deleted.
If file(s) cannot be deleted, no feedback is provided (fail silently).- Parameters:
file- file to be deleted
-
deleteContent
public static void deleteContent(java.io.File dir)
Deletes the specified content of the given directory. Folders are recursively deleted. This method will not delete the given dir, this can be useful in Eclipse or other systems that detect delete-create
If file(s) cannot be deleted, no feedback is provided (fail silently).- Parameters:
dir- of whose contents are to be deleted
-
delete
public static void delete(java.nio.file.Path path)
Deletes the specified path. Folders are recursively deleted.
If file(s) cannot be deleted, no feedback is provided (fail silently).- Parameters:
path- path to be deleted
-
initialize
public static void initialize(java.io.File dir)
Deletes and creates directories
-
deleteWithException
public static void deleteWithException(java.io.File file) throws java.io.IOExceptionDeletes the specified file. Folders are recursively deleted.
Throws exception if any of the files could not be deleted.- Parameters:
file- file to be deleted- Throws:
java.io.IOException- if the file (or contents of a folder) could not be deleted
-
deleteWithException
public static void deleteWithException(java.nio.file.Path path) throws java.io.IOExceptionDeletes the specified path. Folders are recursively deleted.
Throws exception if any of the files could not be deleted.- Parameters:
path- path to be deleted- Throws:
java.io.IOException- if the path (or contents of a folder) could not be deleted
-
rename
public static java.io.File rename(java.io.File from, java.io.File to) throws java.io.IOExceptionRenamesfromtotoreplacing the target file if necessary.- Parameters:
from- source fileto- destination file- Throws:
java.io.IOException- if the rename operation fails
-
rename
public static java.nio.file.Path rename(java.nio.file.Path from, java.nio.file.Path to) throws java.io.IOExceptionRenamesfromtotoreplacing the target file if necessary.- Parameters:
from- source pathto- destination path- Throws:
java.io.IOException- if the rename operation fails
-
mkdirs
public static java.io.File mkdirs(java.io.File dir) throws java.io.IOException- Throws:
java.io.IOException
-
mkdirs
public static java.nio.file.Path mkdirs(java.nio.file.Path dir) throws java.io.IOException- Throws:
java.io.IOException
-
drain
public static long drain(java.io.InputStream in) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static java.io.OutputStream copy(java.util.Collection<?> c, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
close
public static java.lang.Throwable close(java.lang.AutoCloseable in)
-
close
public static java.lang.Throwable close(java.io.Closeable in)
-
closeAll
public static boolean closeAll(java.lang.Object... toBeClosed)
Will iterate over the given toBeClose and silently close any object that implements AutoCloseable.- Parameters:
toBeClosed- any iterable- Returns:
- true if an exception was thrown during closing
-
toURL
public static java.net.URL toURL(java.lang.String s, java.io.File base) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
store
public static void store(java.lang.Object o, java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
store
public static void store(java.lang.Object o, java.io.File file, java.lang.String encoding) throws java.io.IOException- Throws:
java.io.IOException
-
store
public static void store(java.lang.Object o, java.nio.file.Path path, java.nio.charset.Charset encoding) throws java.io.IOException- Throws:
java.io.IOException
-
store
public static void store(java.lang.Object o, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
store
public static void store(java.lang.Object o, java.io.OutputStream out, java.lang.String encoding) throws java.io.IOException- Throws:
java.io.IOException
-
store
public static void store(java.lang.Object o, java.io.OutputStream out, java.nio.charset.Charset encoding) throws java.io.IOException- Throws:
java.io.IOException
-
store
public static void store(java.lang.Object o, java.io.Writer w) throws java.io.IOException- Throws:
java.io.IOException
-
store
public static void store(ConsumerWithException<java.io.OutputStream> store, java.io.File target) throws java.lang.Exception
Store output in a file but ensure that the content is updated atomically. To ensure this, the file is first copied to a temporary file in the same directory as the target. It is then renamed which will first attempt an atomic move but will always replace.- Parameters:
store- the function provide the outputtarget- the file to store it, parent directories will be created if necessary- Throws:
java.lang.Exception
-
stream
public static java.io.InputStream stream(byte[] data)
-
stream
public static java.io.InputStream stream(java.nio.ByteBuffer bb)
-
stream
public static java.io.InputStream stream(java.lang.String s)
-
stream
public static java.io.InputStream stream(java.lang.String s, java.lang.String encoding)
-
stream
public static java.io.InputStream stream(java.lang.String s, java.nio.charset.Charset encoding)
-
stream
public static java.io.InputStream stream(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
stream
public static java.io.InputStream stream(java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
stream
public static java.io.InputStream stream(java.net.URL url) throws java.io.IOException- Throws:
java.io.IOException
-
readChannel
public static java.nio.channels.FileChannel readChannel(java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
outputStream
public static java.io.OutputStream outputStream(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
outputStream
public static java.io.OutputStream outputStream(java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
writeChannel
public static java.nio.channels.FileChannel writeChannel(java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
decode
public static java.nio.CharBuffer decode(java.nio.ByteBuffer bb, java.nio.charset.Charset encoding)
-
encode
public static java.nio.ByteBuffer encode(java.nio.CharBuffer cb, java.nio.charset.Charset encoding)
-
encode
public static java.nio.ByteBuffer encode(java.lang.String s, java.nio.charset.Charset encoding)
-
reader
public static java.io.BufferedReader reader(java.lang.String s)
-
reader
public static java.io.BufferedReader reader(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
reader
public static java.io.BufferedReader reader(java.io.File file, java.lang.String encoding) throws java.io.IOException- Throws:
java.io.IOException
-
reader
public static java.io.BufferedReader reader(java.io.File file, java.nio.charset.Charset encoding) throws java.io.IOException- Throws:
java.io.IOException
-
reader
public static java.io.BufferedReader reader(java.nio.file.Path path, java.nio.charset.Charset encoding) throws java.io.IOException- Throws:
java.io.IOException
-
reader
public static java.io.BufferedReader reader(java.nio.ByteBuffer bb, java.nio.charset.Charset encoding)
-
reader
public static java.io.BufferedReader reader(java.nio.CharBuffer cb)
-
reader
public static java.io.BufferedReader reader(java.nio.channels.ReadableByteChannel in, java.nio.charset.Charset encoding)
-
reader
public static java.io.BufferedReader reader(java.io.InputStream in)
-
reader
public static java.io.BufferedReader reader(java.io.InputStream in, java.lang.String encoding)
-
reader
public static java.io.BufferedReader reader(java.io.InputStream in, java.nio.charset.Charset encoding)
-
writer
public static java.io.PrintWriter writer(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
writer
public static java.io.PrintWriter writer(java.io.File file, java.lang.String encoding) throws java.io.IOException- Throws:
java.io.IOException
-
writer
public static java.io.PrintWriter writer(java.io.File file, java.nio.charset.Charset encoding) throws java.io.IOException- Throws:
java.io.IOException
-
writer
public static java.io.PrintWriter writer(java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
writer
public static java.io.PrintWriter writer(java.nio.file.Path path, java.nio.charset.Charset encoding) throws java.io.IOException- Throws:
java.io.IOException
-
writer
public static java.io.PrintWriter writer(java.nio.channels.WritableByteChannel out, java.nio.charset.Charset encoding)
-
writer
public static java.io.PrintWriter writer(java.io.OutputStream out)
-
writer
public static java.io.PrintWriter writer(java.io.OutputStream out, java.lang.String encoding)
-
writer
public static java.io.PrintWriter writer(java.io.OutputStream out, java.nio.charset.Charset encoding)
-
appendableToWriter
public static java.io.Writer appendableToWriter(java.lang.Appendable appendable)
-
createSymbolicLink
public static boolean createSymbolicLink(java.io.File link, java.io.File target) throws java.io.IOException- Throws:
java.io.IOException
-
createSymbolicLink
public static boolean createSymbolicLink(java.nio.file.Path link, java.nio.file.Path target) throws java.io.IOException- Throws:
java.io.IOException
-
isSymbolicLink
public static boolean isSymbolicLink(java.io.File link)
-
isSymbolicLink
public static boolean isSymbolicLink(java.nio.file.Path link)
-
createSymbolicLinkOrCopy
public static boolean createSymbolicLinkOrCopy(java.io.File link, java.io.File target)Creates a symbolic link fromlinkto thetarget, or copiestargettolinkif running on Windows.Creating symbolic links on Windows requires administrator permissions, so copying is a safer fallback. Copy only happens if timestamp and and file length are different than target
- Parameters:
link- the location of the symbolic link, or destination of the copy.target- the source of the symbolic link, or source of the copy.- Returns:
trueif the operation succeeds,falseotherwise.
-
createSymbolicLinkOrCopy
public static boolean createSymbolicLinkOrCopy(java.nio.file.Path link, java.nio.file.Path target)Creates a symbolic link fromlinkto thetarget, or copiestargettolinkif running on Windows.Creating symbolic links on Windows requires administrator permissions, so copying is a safer fallback. Copy only happens if timestamp and and file length are different than target
- Parameters:
link- the location of the symbolic link, or destination of the copy.target- the source of the symbolic link, or source of the copy.- Returns:
trueif the operation succeeds,falseotherwise.
-
toSafeFileName
public static java.lang.String toSafeFileName(java.lang.String string)
-
isWindows
public static boolean isWindows()
-
readUTF
public static java.lang.String readUTF(java.io.DataInput in) throws java.io.IOException- Throws:
java.io.IOException
-
getJavaExecutablePath
public static java.lang.String getJavaExecutablePath(java.lang.String name)
-
-