Class Overview
Simple utility methods for file and stream copying.
All copy methods use a block size of 4096 bytes,
and close all affected streams when done.
Mainly for use within the framework,
but also useful for application code.
Summary
Public Methods |
static
int
|
copy(Reader in, Writer out)
Copy the contents of the given Reader to the given Writer.
|
static
int
|
copy(InputStream in, OutputStream out)
Copy the contents of the given InputStream to the given OutputStream.
|
static
void
|
copy(byte[] in, OutputStream out)
Copy the contents of the given byte array to the given OutputStream.
|
static
void
|
copy(byte[] in, File out)
Copy the contents of the given byte array to the given output File.
|
static
void
|
copy(String in, Writer out)
Copy the contents of the given String to the given output Writer.
|
static
int
|
copy(File in, File out)
Copy the contents of the given input File to the given output File.
|
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.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
Constants
public
static
final
int
BUFFER_SIZE
Constant Value:
4096
(0x00001000)
Public Constructors
Public Methods
public
static
int
copy
(Reader in, Writer out)
Copy the contents of the given Reader to the given Writer.
Closes both when done.
Parameters
in
| the Reader to copy from |
out
| the Writer to copy to |
Returns
- the number of characters copied
Copy the contents of the given InputStream to the given OutputStream.
Closes both streams when done.
Parameters
in
| the stream to copy from |
out
| the stream to copy to |
Returns
- the number of bytes copied
public
static
void
copy
(byte[] in, OutputStream out)
Copy the contents of the given byte array to the given OutputStream.
Closes the stream when done.
Parameters
in
| the byte array to copy from |
out
| the OutputStream to copy to |
public
static
void
copy
(byte[] in, File out)
Copy the contents of the given byte array to the given output File.
Parameters
in
| the byte array to copy from |
out
| the file to copy to |
public
static
void
copy
(String in, Writer out)
Copy the contents of the given String to the given output Writer.
Closes the write when done.
Parameters
in
| the String to copy from |
out
| the Writer to copy to |
public
static
int
copy
(File in, File out)
Copy the contents of the given input File to the given output File.
Parameters
in
| the file to copy from |
out
| the file to copy to |
Returns
- the number of bytes copied
public
static
byte[]
copyToByteArray
(File in)
Copy the contents of the given input File into a new byte array.
Returns
- the new byte array that has been copied to
public
static
byte[]
copyToByteArray
(InputStream in)
Copy the contents of the given InputStream into a new byte array.
Closes the stream when done.
Parameters
in
| the stream to copy from |
Returns
- the new byte array that has been copied to
public
static
String
copyToString
(Reader in)
Copy the contents of the given Reader into a String.
Closes the reader when done.
Parameters
in
| the reader to copy from |
Returns
- the String that has been copied to