public class IoBase extends Object
Modifier and Type | Field and Description |
---|---|
protected static int |
BULK_TRANSFER_SIZE
The bulk transfer size for
InputStream s and OutputStream s. |
protected static ThreadLocal<Map<String,String>> |
environmentLocal
A mapping of environment variables local to the current thread in support of
beginEnvironment() and
endEnvironment() . |
static InputStream |
nullInputStream
A null
InputStream that has nothing to read. |
static OutputStream |
nullOutputStream
A null
OutputStream to which writes have no effect. |
Modifier and Type | Method and Description |
---|---|
static Map<String,String> |
beginEnvironment()
Begins building the mapping of environment variables for
Thread.currentThread() . |
static void |
close(Closeable closeable)
A
Closeable.close() convenience wrapper. |
static boolean |
copy(File src,
File dst)
Copies a file or directory.
|
static boolean |
delete(File f)
Deletes a file or directory.
|
static void |
endEnvironment()
Ends building the mapping of environment variables for
Thread.currentThread() . |
static int |
execAndWaitFor(InputStream parentIn,
OutputStream parentOut,
OutputStream parentError,
File workingDir,
String... execArgs)
Forks and waits on a new
Process . |
static int |
execAndWaitFor(InputStream parentIn,
OutputStream parentOut,
String... execArgs)
Forks and waits on a new
Process . |
static int |
execAndWaitFor(InputStream parentIn,
String... execArgs)
Forks and waits on a new
Process . |
static int |
execAndWaitFor(OutputStream parentOut,
String... execArgs)
Forks and waits on a new
Process . |
static int |
execAndWaitFor(String... execArgs)
Forks and waits on a new
Process . |
static byte[] |
getBytes(File inFile)
Gets a
byte array from the given file. |
static byte[] |
getBytes(InputStream in)
Gets a
byte array from the given stream. |
static boolean |
isSymbolicLink(File f)
Gets whether the given file is a symbolic link.
|
static void |
transfer(byte[] bytes,
File outFile)
Transfers the contents of a
byte array into a file without appending. |
static void |
transfer(byte[] bytes,
File outFile,
boolean append)
Transfers the contents of a
byte array into a file. |
static void |
transfer(byte[] bytes,
OutputStream out)
Transfers the contents of a
byte array into a stream. |
static void |
transfer(File inFile,
File outFile)
Transfers the contents of a file into a file without appending.
|
static void |
transfer(File inFile,
File outFile,
boolean append)
Transfers the contents of a file into a file.
|
static void |
transfer(File inFile,
OutputStream out)
Transfers the contents of a file into a stream.
|
static void |
transfer(InputStream in,
File outFile)
Transfers the contents of a stream into a file without appending.
|
static void |
transfer(InputStream in,
File outFile,
boolean append)
Transfers the contents of a stream into a file.
|
static void |
transfer(InputStream in,
OutputStream out)
Transfers the contents of one stream into another.
|
protected static final int BULK_TRANSFER_SIZE
InputStream
s and OutputStream
s.public static final OutputStream nullOutputStream
OutputStream
to which writes have no effect.public static final InputStream nullInputStream
InputStream
that has nothing to read.protected static final ThreadLocal<Map<String,String>> environmentLocal
beginEnvironment()
and
endEnvironment()
.public static final void close(Closeable closeable)
Closeable.close()
convenience wrapper.public static final boolean delete(File f)
f
- the file or directory.true
if and only if the file or directory was deleted.public static final boolean copy(File src, File dst)
src
- the source file or directory.dst
- the destination file or directory.true
if and only if the copy operation went smoothly.public static final boolean isSymbolicLink(File f)
public static final void transfer(InputStream in, OutputStream out) throws IOException
in
- the InputStream
.out
- the OutputStream
.IOException
- when something goes awry.public static final void transfer(File inFile, OutputStream out) throws IOException
inFile
- the input File
.out
- the OutputStream
.IOException
- when something goes awry.public static final void transfer(InputStream in, File outFile, boolean append) throws IOException
in
- the InputStream
.outFile
- the output File
.append
- whether this operation overwrites the file, or merely appends onto the end.IOException
- when something goes awry.public static final void transfer(File inFile, File outFile, boolean append) throws IOException
inFile
- the input File
.outFile
- the output File
.append
- whether this operation overwrites the file, or merely appends onto the end.IOException
- when something goes awry.public static final void transfer(InputStream in, File outFile) throws IOException
in
- the InputStream
.outFile
- the output File
.IOException
- when something goes awry.public static final void transfer(File inFile, File outFile) throws IOException
inFile
- the input File
.outFile
- the output File
.IOException
- when something goes awry.public static final void transfer(byte[] bytes, OutputStream out) throws IOException
byte
array into a stream.bytes
- the byte
array.out
- the OutputStream
.IOException
- when something goes awry.public static final void transfer(byte[] bytes, File outFile, boolean append) throws IOException
byte
array into a file.bytes
- the byte
array.outFile
- the output File
.append
- whether this operation overwrites the file, or merely appends onto the end.IOException
- when something goes awry.public static final void transfer(byte[] bytes, File outFile) throws IOException
byte
array into a file without appending.bytes
- the byte
array.outFile
- the output File
.IOException
- when something goes awry.public static final byte[] getBytes(InputStream in) throws IOException
byte
array from the given stream.in
- the InputStream
.byte
array.IOException
- when something goes awry.public static final byte[] getBytes(File inFile) throws IOException
byte
array from the given file.inFile
- the input File
.byte
array.IOException
- when something goes awry.public static final int execAndWaitFor(InputStream parentIn, OutputStream parentOut, OutputStream parentError, File workingDir, String... execArgs) throws IOException
Process
.parentIn
- the InputStream
that contains the child's input.parentOut
- the OutputStream
that receives the child's output.parentError
- the OutputStream
that receives the child's error output.workingDir
- the working directory.execArgs
- the command and arguments to execute.IOException
- when something goes awry.public static final int execAndWaitFor(String... execArgs) throws IOException
Process
.execArgs
- the command and arguments to execute.IOException
- when something goes awry.public static final int execAndWaitFor(InputStream parentIn, String... execArgs) throws IOException
Process
.parentIn
- the InputStream
that contains the child's input.execArgs
- the command and arguments to execute.IOException
- when something goes awry.public static final int execAndWaitFor(OutputStream parentOut, String... execArgs) throws IOException
Process
.parentOut
- the OutputStream
that receives the child's output.execArgs
- the command and arguments to execute.IOException
- when something goes awry.public static final int execAndWaitFor(InputStream parentIn, OutputStream parentOut, String... execArgs) throws IOException
Process
.parentIn
- the InputStream
that contains the child's input.parentOut
- the OutputStream
that receives the child's output.execArgs
- the command and arguments to execute.IOException
- when something goes awry.public static final Map<String,String> beginEnvironment()
Thread.currentThread()
.public static final void endEnvironment()
Thread.currentThread()
.