|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
org.identityconnectors.common.IOUtil
public class IOUtil
IO Utilities
Field Summary | |
---|---|
static java.lang.String |
UTF8 |
Method Summary | |
---|---|
static long |
checksum(java.io.File file) |
static long |
checksum(java.lang.String fileName) Calculates the CRC32 checksum of the specified file. |
static boolean |
copyFile(java.io.File src, java.io.File dest) Copies a file to a destination. |
static long |
copyFile(java.io.InputStream fis, java.io.OutputStream fos) Copies one file to another. |
static void |
delete(java.io.File f) Recursively delete all the files in a directory and the directory. |
static void |
extractResourceToFile(java.lang.Class<?> clazz, java.lang.String path, java.io.File file) Extracts the resource to a file. |
static byte[] |
getResourceAsBytes(java.lang.Class<?> clazz, java.lang.String res) Get the resource as a byte array. |
static java.util.Properties |
getResourceAsProperties(java.lang.ClassLoader loader, java.lang.String path) Loads the given resource as a properties object. |
static java.io.InputStream |
getResourceAsStream(java.lang.Class<?> clazz, java.lang.String res) Returns an input stream of the resource specified. |
static java.lang.String |
getResourceAsString(java.lang.Class<?> clazz, java.lang.String res) Read the entire stream into a String and return it. |
static java.lang.String |
getResourceAsString(java.lang.Class<?> clazz, java.lang.String res, java.nio.charset.Charset charset) Read the entire stream into a String and return it. |
static java.lang.String |
getResourcePath(java.lang.Class<?> c, java.lang.String res) Get the path to a resource base on the package of given class. |
static byte[] |
inputStreamToBytes(java.io.InputStream ins) Takes a 'InputStream' and returns a byte array. |
static java.util.Properties |
loadPropertiesFile(java.io.File f) Loads the given file as a Properties file. |
static java.util.Properties |
loadPropertiesFile(java.lang.String string) Attempt to load file based on a string base filename. |
static java.net.URL |
makeURL(java.io.File dir, java.lang.String path) Make a URL from a directory and path. |
static void |
quietClose(java.io.InputStream stream) Quietly closes the stream. |
static void |
quietClose(java.io.OutputStream stream) Quietly closes the stream. |
static void |
quietClose(java.io.Reader reader) Quietly closes the reader. |
static void |
quietClose(java.io.Writer writer) Quietly closes the Writer. |
static java.lang.String |
readerToString(java.io.Reader rdr) Takes a 'Reader' and returns the contents as a string. |
static byte[] |
readFileBytes(java.io.File file) Reads the given file as bytes |
static java.lang.String |
readFileUTF8(java.io.File file) Reads the given file as UTF-8 |
static byte[] |
readInputStreamBytes(java.io.InputStream is, boolean close) Reads an entire file and returns the bytes. |
static void |
storePropertiesFile(java.io.File f, java.util.Properties properties) Stores the given file as a Properties file. |
static void |
unjar(java.util.jar.JarFile jarFile, java.io.File toDir) Unjars the given file to the given directory. |
static void |
writeFileUTF8(java.io.File file, java.lang.String contents) Write the contents of the string out to a file in UTF-8 format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String UTF8
Method Detail |
---|
public static void quietClose(java.io.Reader reader)
IOException
which may be thrown and ignore it.reader
- - Reader to closepublic static void quietClose(java.io.InputStream stream)
IOException
which may be thrown.stream
- - Stream to closepublic static void quietClose(java.io.Writer writer)
writer
- - Writer to closepublic static void quietClose(java.io.OutputStream stream)
stream
- - Stream to closepublic static java.lang.String getResourcePath(java.lang.Class<?> c, java.lang.String res)
c
- Class to get the package path too.res
- Name of the resource to get the path of.public static java.io.InputStream getResourceAsStream(java.lang.Class<?> clazz, java.lang.String res)
public static byte[] getResourceAsBytes(java.lang.Class<?> clazz, java.lang.String res)
public static java.lang.String getResourceAsString(java.lang.Class<?> clazz, java.lang.String res, java.nio.charset.Charset charset)
public static java.lang.String getResourceAsString(java.lang.Class<?> clazz, java.lang.String res)
public static byte[] inputStreamToBytes(java.io.InputStream ins)
public static java.lang.String readerToString(java.io.Reader rdr)
rdr
- Producer for the string data.public static boolean copyFile(java.io.File src, java.io.File dest) throws java.io.IOException
src
- The source must be a filedest
- This can be a directory or a file.java.io.IOException
public static long copyFile(java.io.InputStream fis, java.io.OutputStream fos) throws java.io.IOException
NOTE: does not close streams.
java.io.IOException
public static long checksum(java.lang.String fileName) throws java.io.IOException, java.io.FileNotFoundException
fileName
- - the path to the file on which to calculate the checksumjava.io.IOException
java.io.FileNotFoundException
public static long checksum(java.io.File file) throws java.io.IOException, java.io.FileNotFoundException
java.io.IOException
java.io.FileNotFoundException
public static byte[] readInputStreamBytes(java.io.InputStream is, boolean close) throws java.io.IOException
close
- if true, close when finished reading.java.io.IOException
public static void delete(java.io.File f) throws java.io.IOException
java.lang.RuntimeException
- iff there is file that can not be deleted.java.io.IOException
public static java.util.Properties loadPropertiesFile(java.io.File f) throws java.io.IOException
java.io.IOException
public static void storePropertiesFile(java.io.File f, java.util.Properties properties) throws java.io.IOException
java.io.IOException
public static java.util.Properties getResourceAsProperties(java.lang.ClassLoader loader, java.lang.String path) throws java.io.IOException
loader
- The class loaderpath
- The path to the resourcejava.io.IOException
- If an error occurs reading itpublic static void extractResourceToFile(java.lang.Class<?> clazz, java.lang.String path, java.io.File file) throws java.io.IOException
clazz
- The class, relative to which path is resolvedpath
- The path to the resourcefile
- The file to extract tojava.io.IOException
- If an error occurs reading itpublic static void unjar(java.util.jar.JarFile jarFile, java.io.File toDir) throws java.io.IOException
jarFile
- The file to unjar.toDir
- The directory to unjar to.java.io.IOException
public static java.lang.String readFileUTF8(java.io.File file) throws java.io.IOException
file
- The file to readjava.io.IOException
- iff there is an issue reading the file.public static byte[] readFileBytes(java.io.File file) throws java.io.IOException
file
- The file to readjava.io.IOException
- iff there is an issue reading the file.public static void writeFileUTF8(java.io.File file, java.lang.String contents) throws java.io.IOException
file
- the file to write to.contents
- the contents of the file to write to.java.io.IOException
- iff there is an issue writing the file.java.lang.NullPointerException
- iff the file parameter is null.public static java.net.URL makeURL(java.io.File dir, java.lang.String path) throws java.io.IOException
dir
- directory to start from.path
- file or path to create the url.java.io.IOException
- iff the URL create from the parameters does not specify a file.public static java.util.Properties loadPropertiesFile(java.lang.String string) throws java.io.IOException
string
- represents the file.java.io.IOException
- if there is an issue.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |