|
Oracle | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.compoze.util.IoUtility
public class IoUtility
This class contains I/O utility methods.
| Nested Class Summary | |
|---|---|
static class |
IoUtility.BynameFilenameFilter
Filter a file by its name. |
| Constructor Summary | |
|---|---|
IoUtility()
|
|
| Method Summary | |
|---|---|
static long |
copyFile(java.io.File sourceFile,
java.io.File destinationFile)
Copy a source file to a destination file, automatically overwriting the destination. |
static long |
copyFile(java.io.File sourceFile,
java.io.File destinationFile,
boolean bOverwrite)
Copy a source file to a destination file. |
static int |
copyReaderToWriter(java.io.Reader reader,
java.io.Writer writer)
This copies data from a reader to a writer. |
static int |
copyReaderToWriter(java.io.Reader reader,
java.io.Writer writer,
int iMaxBytes,
boolean bFlushAndCloseOutput,
boolean bCloseInput)
This copies data from a reader to a writer. |
static int |
copyStream(java.io.InputStream is,
java.io.OutputStream os)
This copies all data from an input stream to an output stream. |
static int |
copyStream(java.io.InputStream is,
java.io.OutputStream os,
int iMaxBytes,
boolean bFlushAndCloseOutput,
boolean bCloseInput)
This copies data from an input stream to an output stream. |
static java.util.Collection |
findFiles(java.io.File baseDir,
java.io.FilenameFilter filter,
boolean bRecursive)
Find a file with the given name underneath a directory. |
static java.util.Collection |
findFiles(java.io.File baseDir,
java.lang.String sFileName)
Find a file with the given name underneath a directory. |
static java.util.Collection |
findFiles(java.io.File baseDir,
java.lang.String sFilename,
boolean bRecursive,
boolean bIgnoreCase)
Find a file with the given name underneath a directory. |
static byte[] |
getBytesFromFile(java.io.File file)
This reads an entire file into a byte array. |
static byte[] |
getBytesFromInputStream(java.io.InputStream is)
This reads an entire InputStream into a byte array. |
static java.io.InputStream |
getInputStreamToStringBuffer(java.lang.StringBuffer buf)
Get an InputStream to a StringBuffer. |
static java.lang.String |
getStringFromFile(java.io.File file)
This reads an entire file into a String. |
static java.lang.String |
getStringFromInputStream(java.io.InputStream is)
This reads an entire InputStream into a String. |
static java.lang.String |
getStringFromInputStream(java.io.InputStream is,
int iMaxLength)
This reads an entire InputStream into a String. |
static void |
main(java.lang.String[] args)
Exerciser. |
static void |
writeStringToFile(java.io.File file,
java.lang.String s)
This writes a string to a file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IoUtility()
| Method Detail |
|---|
public static int copyStream(java.io.InputStream is,
java.io.OutputStream os,
int iMaxBytes,
boolean bFlushAndCloseOutput,
boolean bCloseInput)
throws java.io.IOException
is - InputStream to read fromos - OutputStream to write toiMaxBytes - maximum number of bytes to copy, -1 for no maximumbFlushAndCloseOutput - flush and close OutputStream after copyingbCloseInput - close InputStream after copying
java.io.IOException - if an i/o error occurred
public static int copyStream(java.io.InputStream is,
java.io.OutputStream os)
throws java.io.IOException
is - InputStream to read fromos - OutputStream to write to
java.io.IOException - if an i/o error occurred
public static int copyReaderToWriter(java.io.Reader reader,
java.io.Writer writer,
int iMaxBytes,
boolean bFlushAndCloseOutput,
boolean bCloseInput)
throws java.io.IOException
reader - reader to read fromwriter - writer to write toiMaxBytes - maximum number of characters to copy, -1 for no maximumbFlushAndCloseOutput - flush and close writer after copyingbCloseInput - close reader after copying
java.io.IOException - if an i/o error occurred
public static int copyReaderToWriter(java.io.Reader reader,
java.io.Writer writer)
throws java.io.IOException
reader - reader to read fromwriter - writer to write to
java.io.IOException - if an i/o error occurred
public static java.lang.String getStringFromFile(java.io.File file)
throws java.io.IOException
file - the file to read
java.io.IOException - if an i/o error occurred
public static byte[] getBytesFromFile(java.io.File file)
throws java.io.IOException
file - the file to read
java.io.IOException - if an i/o error occurred
public static java.lang.String getStringFromInputStream(java.io.InputStream is)
throws java.io.IOException
is - the input stream to read
java.io.IOException - if an i/o error occurred
public static java.lang.String getStringFromInputStream(java.io.InputStream is,
int iMaxLength)
throws java.io.IOException
is - the input stream to read
java.io.IOException - if an i/o error occurred
public static byte[] getBytesFromInputStream(java.io.InputStream is)
throws java.io.IOException
is - the input stream to read
java.io.IOException - if an i/o error occurred
public static void writeStringToFile(java.io.File file,
java.lang.String s)
throws java.io.IOException
file - the file to write tos - the string to write
java.io.IOException - if an i/o error occurredpublic static java.io.InputStream getInputStreamToStringBuffer(java.lang.StringBuffer buf)
buf - the string buffer to get an input stream to
public static long copyFile(java.io.File sourceFile,
java.io.File destinationFile)
throws java.io.IOException
sourceFile - the source filedestinationFile - the destination file
java.io.IOException - if an i/o error occurred
public static long copyFile(java.io.File sourceFile,
java.io.File destinationFile,
boolean bOverwrite)
throws java.io.IOException
sourceFile - the source filedestinationFile - the destination filebOverwrite - if true, overwrite the destination file
java.io.IOException - if an i/o error occurred, or the destination
file exists
public static java.util.Collection findFiles(java.io.File baseDir,
java.lang.String sFileName)
throws java.io.IOException
baseDir - the base directory to search undersFileName - the file name to search for
java.io.IOException - if an i/o error occurred
public static java.util.Collection findFiles(java.io.File baseDir,
java.lang.String sFilename,
boolean bRecursive,
boolean bIgnoreCase)
throws java.io.IOException
baseDir - the base directory to search undersFileName - the file name to search forbRecursive - if true, search recursivelybIgnoreCase - if true, ignore case when comparing file names
java.io.IOException - if an i/o error occurred
public static java.util.Collection findFiles(java.io.File baseDir,
java.io.FilenameFilter filter,
boolean bRecursive)
throws java.io.IOException
baseDir - the base directory to search undersFileName - the file name to search forbRecursive - if true, search recursivelybIgnoreCase - if true, ignore case when comparing file names
java.io.IOException - if an i/o error occurredpublic static void main(java.lang.String[] args)
args - command line arguments
|
Oracle | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||