|
Copyright © 2006 BEA Systems, Inc. All Rights Reserved | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.compoze.collab.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(File sourceFile,
File destinationFile)
Copy a source file to a destination file, automatically overwriting the destination. |
static long |
copyFile(File sourceFile,
File destinationFile,
boolean bOverwrite)
Copy a source file to a destination file. |
static int |
copyReaderToWriter(Reader reader,
Writer writer)
This copies data from a reader to a writer. |
static int |
copyReaderToWriter(Reader reader,
Writer writer,
int iMaxBytes,
boolean bFlushAndCloseOutput,
boolean bCloseInput)
This copies data from a reader to a writer. |
static int |
copyStream(InputStream is,
OutputStream os)
This copies all data from an input stream to an output stream. |
static int |
copyStream(InputStream is,
OutputStream os,
int iMaxBytes,
boolean bFlushAndCloseOutput,
boolean bCloseInput)
This copies data from an input stream to an output stream. |
static Collection |
findFiles(File baseDir,
FilenameFilter filter,
boolean bRecursive)
Find a file with the given name underneath a directory. |
static Collection |
findFiles(File baseDir,
String sFileName)
Find a file with the given name underneath a directory. |
static Collection |
findFiles(File baseDir,
String sFilename,
boolean bRecursive,
boolean bIgnoreCase)
Find a file with the given name underneath a directory. |
static byte[] |
getBytesFromFile(File file)
This reads an entire file into a byte array. |
static byte[] |
getBytesFromInputStream(InputStream is)
This reads an entire InputStream into a byte array. |
static InputStream |
getInputStreamToStringBuffer(StringBuffer buf)
Get an InputStream to a StringBuffer. |
static Object |
getObjectFromFile(File f)
Gets a serialized object from a File . |
static Object |
getObjectFromFile(String sFile)
Gets a serialized object from a File . |
static Object |
getObjectFromStream(InputStream is)
Gets a serialized object from an InputStream . |
static String |
getStringFromFile(File file)
This reads an entire file into a String. |
static String |
getStringFromInputStream(InputStream is)
This reads an entire InputStream into a String. |
static String |
getStringFromInputStream(InputStream is,
int iMaxLength)
This reads an entire InputStream into a String. |
static void |
main(String[] args)
Exerciser. |
static void |
writeObjectToFile(Object obj,
File f)
Writes a serialized object to a file. |
static void |
writeObjectToFile(Object obj,
String sFile)
Writes a serialized object to a file. |
static void |
writeObjectToStream(Object obj,
OutputStream os,
boolean bClose)
Writes a serialized object to an OutputStream . |
static void |
writeStringToFile(File file,
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(InputStream is, OutputStream os, int iMaxBytes, boolean bFlushAndCloseOutput, boolean bCloseInput) throws 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
IOException
- if an i/o error occurredpublic static int copyStream(InputStream is, OutputStream os) throws IOException
is
- InputStream to read fromos
- OutputStream to write to
IOException
- if an i/o error occurredpublic static int copyReaderToWriter(Reader reader, Writer writer, int iMaxBytes, boolean bFlushAndCloseOutput, boolean bCloseInput) throws 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
IOException
- if an i/o error occurredpublic static int copyReaderToWriter(Reader reader, Writer writer) throws IOException
reader
- reader to read fromwriter
- writer to write to
IOException
- if an i/o error occurredpublic static Object getObjectFromStream(InputStream is) throws IOException, ClassNotFoundException
InputStream
.
is
- the input stream (not null
)
IOException
ClassNotFoundException
public static Object getObjectFromFile(File f) throws IOException, ClassNotFoundException
File
.
f
- the file (not null
)
IOException
ClassNotFoundException
public static Object getObjectFromFile(String sFile) throws IOException, ClassNotFoundException
File
.
sFile
- the filename (not null
)
IOException
ClassNotFoundException
public static void writeObjectToStream(Object obj, OutputStream os, boolean bClose) throws IOException
OutputStream
.
obj
- the object to writeos
- the output stream (not null
)bClose
- if true
, close the stream afterwards
IOException
public static void writeObjectToFile(Object obj, File f) throws IOException
IOException
public static void writeObjectToFile(Object obj, String sFile) throws IOException
IOException
public static String getStringFromFile(File file) throws IOException
file
- the file to read
IOException
- if an i/o error occurredpublic static byte[] getBytesFromFile(File file) throws IOException
file
- the file to read
IOException
- if an i/o error occurredpublic static String getStringFromInputStream(InputStream is) throws IOException
is
- the input stream to read
IOException
- if an i/o error occurredpublic static String getStringFromInputStream(InputStream is, int iMaxLength) throws IOException
is
- the input stream to read
IOException
- if an i/o error occurredpublic static byte[] getBytesFromInputStream(InputStream is) throws IOException
is
- the input stream to read
IOException
- if an i/o error occurredpublic static void writeStringToFile(File file, String s) throws IOException
file
- the file to write tos
- the string to write
IOException
- if an i/o error occurredpublic static InputStream getInputStreamToStringBuffer(StringBuffer buf)
buf
- the string buffer to get an input stream to
public static long copyFile(File sourceFile, File destinationFile) throws IOException
sourceFile
- the source filedestinationFile
- the destination file
IOException
- if an i/o error occurredpublic static long copyFile(File sourceFile, File destinationFile, boolean bOverwrite) throws IOException
sourceFile
- the source filedestinationFile
- the destination filebOverwrite
- if true, overwrite the destination file
IOException
- if an i/o error occurred, or the destination
file existspublic static Collection findFiles(File baseDir, String sFileName) throws IOException
baseDir
- the base directory to search undersFileName
- the file name to search for
IOException
- if an i/o error occurredpublic static Collection findFiles(File baseDir, String sFilename, boolean bRecursive, boolean bIgnoreCase) throws 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
IOException
- if an i/o error occurredpublic static Collection findFiles(File baseDir, FilenameFilter filter, boolean bRecursive) throws 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
IOException
- if an i/o error occurredpublic static void main(String[] args)
args
- command line arguments
|
Copyright © 2006 BEA Systems, Inc. All Rights Reserved | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |