|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.io.FileUtils
public class FileUtils
FileUtils utility class extracted from the Spring Framework in order to remove the dependency on Spring for this one class. issue 2 (remove unneccessary dependencies)
| Constructor Summary | |
|---|---|
FileUtils()
|
|
| Method Summary | |
|---|---|
static void |
closeQuietly(java.io.InputStream input)
Unconditionally
close an |
static void |
copy(java.io.InputStream input,
java.io.Writer output)
Copy bytes from an InputStream to chars on a
Writer using the default character encoding of the
platform.
|
static void |
copy(java.io.InputStream inputStream,
java.io.Writer outputStream,
java.lang.String encoding)
Copy bytes from an InputStream to chars on a
Writer using the specified character encoding.
|
static void |
copy(java.io.Reader input,
java.io.OutputStream output)
Copy
chars from a |
static int |
copy(java.io.Reader input,
java.io.Writer output)
Copy chars from a Reader to a Writer.
|
static java.lang.String |
readFileToString(java.io.File file,
java.lang.String encoding)
Reads the contents of a file into a String. |
static java.lang.String |
toString(java.io.InputStream input,
java.lang.String encoding)
Get the contents of an InputStream as a String using the
specified character encoding.
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify,
notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileUtils()
| Method Detail |
|---|
public static java.lang.String readFileToString(java.io.File file,
java.lang.String encoding)
throws java.io.IOException
Reads the contents of a file into a String. There is no readFileToString method without encoding parameter because the default encoding can differ between platforms and therefore results in inconsistent results.
file - the file to read
encoding - the encoding to use, null means platform
default
java.io.IOException - in case of an I/O error
java.io.UnsupportedEncodingException - if the
encoding is not supported by
the VM
public static java.lang.String toString(java.io.InputStream input,
java.lang.String encoding)
throws java.io.IOException
Get the contents of an InputStream as a String using the
specified character encoding.
Character encoding names can be found at IANA.
This method buffers the input internally, so there is no need to use
a
BufferedInputStream.
input - the InputStream to read from
encoding - the encoding to use, null means platform
default
java.lang.NullPointerException - if the input is
null
java.io.IOException - if an I/O error occurs
public static void copy(java.io.InputStream input,
java.io.Writer output)
throws java.io.IOException
Copy bytes from an InputStream to chars on a
Writer using the default character encoding of the
platform.
This method buffers the input internally, so there is no need to use
a BufferedInputStream.
This method uses InputStreamReader.
input - the InputStream to read from
output - the Writer to write to
java.lang.NullPointerException - if the input or
output is null
java.io.IOException - if an I/O error occurs
public static void copy(java.io.InputStream inputStream,
java.io.Writer outputStream,
java.lang.String encoding)
throws java.io.IOException
Copy bytes from an InputStream to chars on a
Writer using the specified character encoding.
This
method buffers the inputStream internally, so there is no need to
use a
BufferedInputStream.
Character encoding names can be found at IANA.
This method uses InputStreamReader.
inputStream - the InputStream to read
from
outputStream - the Writer to write to
encoding - the encoding to use, null means platform
default
java.lang.NullPointerException - if the inputStream
or outputStream is null
java.io.IOException - if an I/O error occurs
public static int copy(java.io.Reader input,
java.io.Writer output)
throws java.io.IOException
Copy chars from a Reader to a Writer.
This method buffers the input internally, so there is no need to use
a
BufferedReader.
input - the Reader to read from
output - the Writer to write to
java.lang.NullPointerException - if the input or
output is null
java.io.IOException - if an I/O error occurs
public static void copy(java.io.Reader input,
java.io.OutputStream output)
throws java.io.IOException
Copy chars from a Reader to bytes on an
OutputStream using the default character encoding of the
platform, and calling flush. This method buffers the input
internally, so there is no need to use a BufferedReader.
Due to the implementation of OutputStreamWriter, this method
performs a
flush.
This method uses OutputStreamWriter.
input - the Reader to read from
output - the OutputStream to write to
java.lang.NullPointerException - if the input or
output is null
java.io.IOException - if an I/O error occurs
public static void closeQuietly(java.io.InputStream input)
Unconditionally close an InputStream. Equivalent
to InputStream.close(), except any exceptions will be
ignored.
This is typically used in finally blocks.
input - the InputStream to close, may be null or
already closed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||