|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.seventytwomiles.springframework.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 unnecessary dependencies)
| Constructor Summary | |
|---|---|
FileUtils()
|
|
| Method Summary | |
|---|---|
static void |
closeQuietly(InputStream input)
Unconditionally close an |
static void |
copy(InputStream input,
Writer output)
Copy bytes from an InputStream to chars on a
Writer using the default character encoding of the platform. |
static void |
copy(InputStream inputStream,
Writer outputStream,
String encoding)
Copy bytes from an InputStream to chars on a
Writer using the specified character encoding. |
static void |
copy(Reader input,
OutputStream output)
Copy chars from a |
static int |
copy(Reader input,
Writer output)
Copy chars from a Reader to a Writer. |
static String |
readFileToString(File file,
String encoding)
Reads the contents of a file into a String. |
static String |
toString(InputStream input,
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 String readFileToString(File file,
String encoding)
throws 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 readencoding - the encoding to use, null means platform default
IOException - in case of an I/O error
UnsupportedEncodingException - if the encoding is not supported by
the VM
public static String toString(InputStream input,
String encoding)
throws 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 fromencoding - the encoding to use, null means platform default
NullPointerException - if the input is null
IOException - if an I/O error occurs
public static void copy(InputStream input,
Writer output)
throws 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 fromoutput - the Writer to write to
NullPointerException - if the input or output is null
IOException - if an I/O error occurs
public static void copy(InputStream inputStream,
Writer outputStream,
String encoding)
throws 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 fromoutputStream - the Writer to write toencoding - the encoding to use, null means platform default
NullPointerException - if the inputStream or outputStream is null
IOException - if an I/O error occurs
public static int copy(Reader input,
Writer output)
throws 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 fromoutput - the Writer to write to
NullPointerException - if the input or output is null
IOException - if an I/O error occurs
public static void copy(Reader input,
OutputStream output)
throws 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 fromoutput - the OutputStream to write to
NullPointerException - if the input or output is null
IOException - if an I/O error occurspublic static void closeQuietly(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 | |||||||||