public abstract class FileCopyUtils extends Object
StreamUtils
.
Mainly for use within the framework, but also useful for application code.
StreamUtils
,
FileSystemUtils
Modifier and Type | Field and Description |
---|---|
static int |
BUFFER_SIZE
The default buffer size used when copying bytes.
|
Constructor and Description |
---|
FileCopyUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
copy(byte[] in,
File out)
Copy the contents of the given byte array to the given output File.
|
static void |
copy(byte[] in,
OutputStream out)
Copy the contents of the given byte array to the given OutputStream.
|
static int |
copy(File in,
File out)
Copy the contents of the given input File to the given output File.
|
static int |
copy(InputStream in,
OutputStream out)
Copy the contents of the given InputStream to the given OutputStream.
|
static int |
copy(Reader in,
Writer out)
Copy the contents of the given Reader to the given Writer.
|
static void |
copy(String in,
Writer out)
Copy the contents of the given String to the given Writer.
|
static byte[] |
copyToByteArray(File in)
Copy the contents of the given input File into a new byte array.
|
static byte[] |
copyToByteArray(InputStream in)
Copy the contents of the given InputStream into a new byte array.
|
static String |
copyToString(Reader in)
Copy the contents of the given Reader into a String.
|
public static final int BUFFER_SIZE
public static int copy(File in, File out) throws IOException
in
- the file to copy fromout
- the file to copy toIOException
- in case of I/O errorspublic static void copy(byte[] in, File out) throws IOException
in
- the byte array to copy fromout
- the file to copy toIOException
- in case of I/O errorspublic static byte[] copyToByteArray(File in) throws IOException
in
- the file to copy fromIOException
- in case of I/O errorspublic static int copy(InputStream in, OutputStream out) throws IOException
in
- the stream to copy fromout
- the stream to copy toIOException
- in case of I/O errorspublic static void copy(byte[] in, OutputStream out) throws IOException
in
- the byte array to copy fromout
- the OutputStream to copy toIOException
- in case of I/O errorspublic static byte[] copyToByteArray(@Nullable InputStream in) throws IOException
in
- the stream to copy from (may be null
or empty)IOException
- in case of I/O errorspublic static int copy(Reader in, Writer out) throws IOException
in
- the Reader to copy fromout
- the Writer to copy toIOException
- in case of I/O errorspublic static void copy(String in, Writer out) throws IOException
in
- the String to copy fromout
- the Writer to copy toIOException
- in case of I/O errorspublic static String copyToString(@Nullable Reader in) throws IOException
in
- the reader to copy from (may be null
or empty)IOException
- in case of I/O errors