|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sodius.mdw.core.util.io.IOUtils
public final class IOUtils
General I/O stream manipulation utilities.
| Method Summary | |
|---|---|
static void |
closeQuietly(InputStream input)
Unconditionally close an InputStream. |
static void |
closeQuietly(OutputStream output)
Unconditionally close an OutputStream. |
static void |
closeQuietly(Reader reader)
Unconditionally close a Reader. |
static void |
closeQuietly(Writer writer)
Unconditionally close a Writer. |
static void |
copy(File input,
File output)
Copy bytes from one File to another File. |
static void |
copy(InputStream input,
OutputStream output)
Copy bytes from an InputStream to an OutputStream. |
static void |
copy(Reader reader,
Writer writer)
Copy characters from a Reader to a Writer. |
static URI |
createURI(String uri)
Parses an URI string. |
static File |
getAbsoluteFile(File relativeFile,
File directory)
Returns the absolute form of the specified relative file, using the specified directory to compute this absolute path. |
static String |
getFileExtension(File file)
Returns the extension of the specified File. |
static String |
getFileExtension(String filename)
Returns the extension of the specified file name. |
static byte[] |
toByteArray(File file)
Get the contents of a File as a byte array. |
static byte[] |
toByteArray(InputStream input)
Get the contents of an InputStream as a byte array. |
static String |
toString(File file,
String charsetName)
Get the contents of a File 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 |
| Method Detail |
|---|
public static String getFileExtension(File file)
File.
The file extension portion is defined as the string following the last period (".") character in the name. If there is no period in the name, the path has no file extension portion. If the name ends in a period, the file extension portion is the empty string.
null if the file has no extension.public static String getFileExtension(String filename)
The file extension portion is defined as the string following the last period (".") character in the name. If there is no period in the name, the path has no file extension portion. If the name ends in a period, the file extension portion is the empty string.
null if the file has no extension.
public static File getAbsoluteFile(File relativeFile,
File directory)
This method does the same job as ,
but uses the specified directory to compute the absolute file
instead of the current user directory.
File.getAbsoluteFile()
relativeFile - the relative file.directory - the reference directory (to use in place of the current user directory).
public static String toString(File file,
String charsetName)
throws IOException
File as a String using the specified character encoding.
file - the file to read from.charsetName - the encoding to use, null means platform default.
String.
IOException - if an I/O error occurs.
public static byte[] toByteArray(File file)
throws IOException
File as a byte array.
file - the file to read from.
byte array.
IOException - if an I/O error occurs.
public static byte[] toByteArray(InputStream input)
throws IOException
InputStream as a byte array.
input - the stream to read from.
byte array.
IOException - if an I/O error occurs.
public static void copy(InputStream input,
OutputStream output)
throws IOException
InputStream to an OutputStream.
This method buffers the input internally, so there is no need to use a BufferedInputStream.
IOException - if an I/O error occurs
public static void copy(File input,
File output)
throws IOException
File to another File.
IOException - if an I/O error occurs
IllegalArgumentException - if input or output is a directory
public static void copy(Reader reader,
Writer writer)
throws IOException
Reader to a Writer.
This method buffers the input internally, so there is no need to use a BufferedReader.
IOException - if an I/O error occurspublic static void closeQuietly(InputStream input)
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 closedpublic static void closeQuietly(OutputStream output)
OutputStream.
Equivalent to OutputStream.close(), except any exceptions will be ignored.
This is typically used in finally blocks.
output - the OutputStream to close, may be null or already closedpublic static void closeQuietly(Reader reader)
Reader.
Equivalent to Reader.close(), except any exceptions will be ignored.
This is typically used in finally blocks.
reader - the Reader to close, may be null or already closedpublic static void closeQuietly(Writer writer)
Writer.
Equivalent to Writer.close(), except any exceptions will be ignored.
This is typically used in finally blocks.
writer - the Writer to close, may be null or already closedpublic static URI createURI(String uri)
File.exists()).
Otherwise URI.createURI(String) is called.
URI#createURI(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||