|
Compoze Software, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.compoze.util.IoUtility
This class contains I/O utility methods.
Inner 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 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 copyingjava.io.IOException
- if an i/o error occurredpublic static int copyStream(java.io.InputStream is, java.io.OutputStream os) throws java.io.IOException
is
- InputStream to read fromos
- OutputStream to write tojava.io.IOException
- if an i/o error occurredpublic 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 copyingjava.io.IOException
- if an i/o error occurredpublic static int copyReaderToWriter(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
reader
- reader to read fromwriter
- writer to write tojava.io.IOException
- if an i/o error occurredpublic static java.lang.String getStringFromFile(java.io.File file) throws java.io.IOException
file
- the file to readjava.io.IOException
- if an i/o error occurredpublic static byte[] getBytesFromFile(java.io.File file) throws java.io.IOException
file
- the file to readjava.io.IOException
- if an i/o error occurredpublic static java.lang.String getStringFromInputStream(java.io.InputStream is) throws java.io.IOException
is
- the input stream to readjava.io.IOException
- if an i/o error occurredpublic static byte[] getBytesFromInputStream(java.io.InputStream is) throws java.io.IOException
is
- the input stream to readjava.io.IOException
- if an i/o error occurredpublic static void writeStringToFile(java.io.File file, java.lang.String s) throws java.io.IOException
file
- the file to write tos
- the string to writejava.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 topublic static long copyFile(java.io.File sourceFile, java.io.File destinationFile) throws java.io.IOException
sourceFile
- the source filedestinationFile
- the destination filejava.io.IOException
- if an i/o error occurredpublic 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 filejava.io.IOException
- if an i/o error occurred, or the destination
file existspublic 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 forjava.io.IOException
- if an i/o error occurredpublic 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 namesjava.io.IOException
- if an i/o error occurredpublic 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 namesjava.io.IOException
- if an i/o error occurredpublic static void main(java.lang.String[] args)
args
- command line arguments
|
Compoze Software, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |