public class IO extends Object
| Modifier and Type | Field and Description |
|---|---|
static File |
home |
static File |
JAVA_HOME |
static OutputStream |
nullStream |
static Writer |
nullWriter |
static File |
work |
| Constructor and Description |
|---|
IO() |
public static final File work
public static final File home
public static final File JAVA_HOME
public static final OutputStream nullStream
public static final Writer nullWriter
public static Collection<File> tree(File current)
public static Collection<File> tree(File current, String glob)
public static File copy(byte[] data, File file) throws IOException
IOExceptionpublic static Path copy(byte[] data, Path path) throws IOException
IOExceptionpublic static Writer copy(byte[] data, Writer w) throws IOException
IOExceptionpublic static OutputStream copy(byte[] data, OutputStream out) throws IOException
IOExceptionpublic static Writer copy(Reader r, Writer w) throws IOException
IOExceptionpublic static OutputStream copy(Reader r, OutputStream out) throws IOException
IOExceptionpublic static OutputStream copy(Reader r, OutputStream out, String charset) throws IOException
IOExceptionpublic static OutputStream copy(Reader r, OutputStream out, Charset charset) throws IOException
IOExceptionpublic static Writer copy(InputStream in, Writer w) throws IOException
IOExceptionpublic static Writer copy(InputStream in, Writer w, String charset) throws IOException
IOExceptionpublic static Writer copy(InputStream in, Writer w, Charset charset) throws IOException
IOExceptionpublic static OutputStream copy(InputStream in, OutputStream out) throws IOException
IOExceptionpublic static ByteBufferOutputStream copy(InputStream in, ByteBufferOutputStream out) throws IOException
IOExceptionpublic static DataOutput copy(InputStream in, DataOutput out) throws IOException
IOExceptionpublic static WritableByteChannel copy(ReadableByteChannel in, WritableByteChannel out) throws IOException
IOExceptionpublic static ByteBuffer copy(InputStream in, ByteBuffer bb) throws IOException
IOExceptionpublic static byte[] copy(InputStream in, byte[] data) throws IOException
IOExceptionpublic static byte[] copy(InputStream in, byte[] data, int off, int len) throws IOException
IOExceptionpublic static OutputStream copy(ByteBuffer bb, OutputStream out) throws IOException
IOExceptionpublic static DataOutput copy(ByteBuffer bb, DataOutput out) throws IOException
IOExceptionpublic static MessageDigest copy(URL url, MessageDigest md) throws IOException
IOExceptionpublic static MessageDigest copy(File file, MessageDigest md) throws IOException
IOExceptionpublic static MessageDigest copy(Path path, MessageDigest md) throws IOException
IOExceptionpublic static MessageDigest copy(URLConnection conn, MessageDigest md) throws IOException
IOExceptionpublic static MessageDigest copy(InputStream in, MessageDigest md) throws IOException
IOExceptionpublic static MessageDigest copy(ReadableByteChannel in, MessageDigest md) throws IOException
IOExceptionpublic static File copy(URL url, File file) throws IOException
IOExceptionpublic static File copy(URLConnection conn, File file) throws IOException
IOExceptionpublic static URL copy(InputStream in, URL url) throws IOException
IOExceptionpublic static URL copy(InputStream in, URL url, String method) throws IOException
IOExceptionpublic static File copy(File src, File tgt) throws IOException
IOExceptionpublic static Path copy(Path src, Path tgt) throws IOException
IOExceptionpublic static File copy(InputStream in, File file) throws IOException
IOExceptionpublic static Path copy(InputStream in, Path path) throws IOException
IOExceptionpublic static OutputStream copy(File file, OutputStream out) throws IOException
IOExceptionpublic static OutputStream copy(Path path, OutputStream out) throws IOException
IOExceptionpublic static WritableByteChannel copy(InputStream in, WritableByteChannel out) throws IOException
IOExceptionpublic static OutputStream copy(ReadableByteChannel in, OutputStream out) throws IOException
IOExceptionpublic static byte[] read(File file) throws IOException
IOExceptionpublic static ByteBuffer read(Path path) throws IOException
IOExceptionpublic static byte[] read(ByteBuffer bb)
public static byte[] read(URL url) throws IOException
IOExceptionpublic static byte[] read(InputStream in) throws IOException
IOExceptionpublic static void write(byte[] data,
OutputStream out)
throws IOException
IOExceptionpublic static void write(byte[] data,
File file)
throws IOException
IOExceptionpublic static String collect(File file) throws IOException
IOExceptionpublic static String collect(File file, String encoding) throws IOException
IOExceptionpublic static String collect(File file, Charset encoding) throws IOException
IOExceptionpublic static String collect(Path path) throws IOException
IOExceptionpublic static String collect(Path path, Charset encoding) throws IOException
IOExceptionpublic static String collect(ByteBuffer bb, Charset encoding)
public static String collect(URL url, String encoding) throws IOException
IOExceptionpublic static String collect(URL url, Charset encoding) throws IOException
IOExceptionpublic static String collect(URL url) throws IOException
IOExceptionpublic static String collect(String path) throws IOException
IOExceptionpublic static String collect(InputStream in) throws IOException
IOExceptionpublic static String collect(InputStream in, String encoding) throws IOException
IOExceptionpublic static String collect(InputStream in, Charset encoding) throws IOException
IOExceptionpublic static String collect(Reader r) throws IOException
IOExceptionpublic static File createTempFile(File directory, String pattern, String suffix) throws IllegalArgumentException, IOException
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 usedIllegalArgumentException - when pattern is null or too shortIOException - when the specified (non-null) directory is not a
directorypublic static File getBasedFile(File base, String file) throws IOException
IOExceptionpublic static Path getBasedPath(Path base, String file) throws IOException
IOExceptionpublic static void delete(File file)
file - file to be deletedpublic static void delete(Path path)
path - path to be deletedpublic static void initialize(File dir)
public static void deleteWithException(File file) throws IOException
file - file to be deletedIOException - if the file (or contents of a folder) could not be
deletedpublic static void deleteWithException(Path path) throws IOException
path - path to be deletedIOException - if the path (or contents of a folder) could not be
deletedpublic static File rename(File from, File to) throws IOException
from to to replacing the target file if
necessary.from - source fileto - destination fileIOException - if the rename operation failspublic static Path rename(Path from, Path to) throws IOException
from to to replacing the target file if
necessary.from - source pathto - destination pathIOException - if the rename operation failspublic static File mkdirs(File dir) throws IOException
IOExceptionpublic static Path mkdirs(Path dir) throws IOException
IOExceptionpublic static long drain(InputStream in) throws IOException
IOExceptionpublic static OutputStream copy(Collection<?> c, OutputStream out) throws IOException
IOExceptionpublic static Throwable close(AutoCloseable in)
public static URL toURL(String s, File base) throws MalformedURLException
MalformedURLExceptionpublic static void store(Object o, File file) throws IOException
IOExceptionpublic static void store(Object o, File file, String encoding) throws IOException
IOExceptionpublic static void store(Object o, Path path, Charset encoding) throws IOException
IOExceptionpublic static void store(Object o, OutputStream out) throws IOException
IOExceptionpublic static void store(Object o, OutputStream out, String encoding) throws IOException
IOExceptionpublic static void store(Object o, OutputStream out, Charset encoding) throws IOException
IOExceptionpublic static void store(Object o, Writer w) throws IOException
IOExceptionpublic static InputStream stream(byte[] data)
public static InputStream stream(ByteBuffer bb)
public static InputStream stream(String s)
public static InputStream stream(String s, String encoding)
public static InputStream stream(String s, Charset encoding)
public static InputStream stream(File file) throws IOException
IOExceptionpublic static InputStream stream(Path path) throws IOException
IOExceptionpublic static InputStream stream(URL url) throws IOException
IOExceptionpublic static FileChannel readChannel(Path path) throws IOException
IOExceptionpublic static OutputStream outputStream(File file) throws IOException
IOExceptionpublic static OutputStream outputStream(Path path) throws IOException
IOExceptionpublic static FileChannel writeChannel(Path path) throws IOException
IOExceptionpublic static CharBuffer decode(ByteBuffer bb, Charset encoding)
public static ByteBuffer encode(CharBuffer cb, Charset encoding)
public static BufferedReader reader(String s)
public static BufferedReader reader(File file) throws IOException
IOExceptionpublic static BufferedReader reader(File file, String encoding) throws IOException
IOExceptionpublic static BufferedReader reader(File file, Charset encoding) throws IOException
IOExceptionpublic static BufferedReader reader(Path path, Charset encoding) throws IOException
IOExceptionpublic static BufferedReader reader(ByteBuffer bb, Charset encoding)
public static BufferedReader reader(CharBuffer cb)
public static BufferedReader reader(ReadableByteChannel in, Charset encoding)
public static BufferedReader reader(InputStream in)
public static BufferedReader reader(InputStream in, String encoding)
public static BufferedReader reader(InputStream in, Charset encoding)
public static PrintWriter writer(File file) throws IOException
IOExceptionpublic static PrintWriter writer(File file, String encoding) throws IOException
IOExceptionpublic static PrintWriter writer(File file, Charset encoding) throws IOException
IOExceptionpublic static PrintWriter writer(Path path) throws IOException
IOExceptionpublic static PrintWriter writer(Path path, Charset encoding) throws IOException
IOExceptionpublic static PrintWriter writer(WritableByteChannel out, Charset encoding)
public static PrintWriter writer(OutputStream out)
public static PrintWriter writer(OutputStream out, String encoding)
public static PrintWriter writer(OutputStream out, Charset encoding)
public static boolean createSymbolicLink(File link, File target) throws IOException
IOExceptionpublic static boolean createSymbolicLink(Path link, Path target) throws IOException
IOExceptionpublic static boolean isSymbolicLink(File link)
public static boolean isSymbolicLink(Path link)
public static boolean createSymbolicLinkOrCopy(File link, File target)
link to the target, or
copies target to link if 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
link - the location of the symbolic link, or destination of the
copy.target - the source of the symbolic link, or source of the copy.true if the operation succeeds, false otherwise.public static boolean createSymbolicLinkOrCopy(Path link, Path target)
link to the target, or
copies target to link if 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
link - the location of the symbolic link, or destination of the
copy.target - the source of the symbolic link, or source of the copy.true if the operation succeeds, false otherwise.public static boolean isWindows()
public static String readUTF(DataInput in) throws IOException
IOExceptionCopyright © 2021. All rights reserved.