| java.lang.Object org.archive.util.IoUtils
IoUtils | public class IoUtils (Code) | | I/O Utility methods.
author: stack version: $Date: 2007-02-20 23:25:20 +0000 (Tue, 20 Feb 2007) $, $Revision: 4919 $ |
Method Summary | |
public static Object | deserializeFromByteArray(byte[] in) Utility method to deserialize Object from byte[]. | public static Object | deserializeFromFile(File file) Utility method to deserialize an Object from given File. | public static float | encodingMaxBytesPerChar(String encoding) Return the maximum number of bytes per character in the named
encoding, or 0 if encoding is invalid or unsupported. | public static File | ensureWriteableDirectory(String dir) Ensure writeable directory.
If doesn't exist, we attempt creation.
Parameters: dir - Directory to test for exitence and is writeable. | public static List | ensureWriteableDirectory(List<File> dirs) Ensure writeable directories.
If doesn't exist, we attempt creation.
Parameters: dirs - List of Files to test. | public static File | ensureWriteableDirectory(File dir) Ensure writeable directory.
If doesn't exist, we attempt creation.
Parameters: dir - Directory to test for exitence and is writeable. | public static String | getClasspathPath(File file) Parameters: file - File to operate on. | public static void | readFully(InputStream input, byte[] buf) | public static String | readFullyAsString(InputStream inputStream) Read the entire stream to EOF, returning what's read as a String. | public static void | readFullyToFile(InputStream is, File toFile) Read the entire stream to EOF into the passed file. | public static long | readFullyToFile(InputStream is, File toFile, byte[] buffer) Read the entire stream to EOF into the passed file.
Closes is when done or if an exception.
Parameters: is - Stream to read. Parameters: toFile - File to read into . Parameters: buffer - Buffer to use reading. | public static byte[] | serializeToByteArray(Object object) Utility method to serialize Object to byte[]. | public static void | serializeToFile(Object object, File file) Utility method to serialize an object to the given File. | public static IOException | wrapAsIOException(Throwable e) |
deserializeFromByteArray | public static Object deserializeFromByteArray(byte[] in)(Code) | | Utility method to deserialize Object from byte[].
Parameters: in - byte[] source Object deserialized |
deserializeFromFile | public static Object deserializeFromFile(File file) throws IOException(Code) | | Utility method to deserialize an Object from given File.
Parameters: file - File source deserialized Object throws: IOException - |
encodingMaxBytesPerChar | public static float encodingMaxBytesPerChar(String encoding)(Code) | | Return the maximum number of bytes per character in the named
encoding, or 0 if encoding is invalid or unsupported.
Parameters: encoding - Encoding to consider. For now, should be java canonical name for the encoding. True if multibyte encoding. |
ensureWriteableDirectory | public static File ensureWriteableDirectory(String dir) throws IOException(Code) | | Ensure writeable directory.
If doesn't exist, we attempt creation.
Parameters: dir - Directory to test for exitence and is writeable. The passed dir . exception: IOException - If passed directory does not exist and is notcreateable, or directory is not writeable or is not a directory. |
ensureWriteableDirectory | public static List ensureWriteableDirectory(List<File> dirs) throws IOException(Code) | | Ensure writeable directories.
If doesn't exist, we attempt creation.
Parameters: dirs - List of Files to test. The passed dirs . exception: IOException - If passed directory does not exist and is notcreateable, or directory is not writeable or is not a directory. |
ensureWriteableDirectory | public static File ensureWriteableDirectory(File dir) throws IOException(Code) | | Ensure writeable directory.
If doesn't exist, we attempt creation.
Parameters: dir - Directory to test for exitence and is writeable. The passed dir . exception: IOException - If passed directory does not exist and is notcreateable, or directory is not writeable or is not a directory. |
getClasspathPath | public static String getClasspathPath(File file)(Code) | | Parameters: file - File to operate on. Path suitable for use getting resources off the CLASSPATH(CLASSPATH resources always use '/' as path separator, even onwindows). |
readFullyAsString | public static String readFullyAsString(InputStream inputStream) throws IOException(Code) | | Read the entire stream to EOF, returning what's read as a String.
Parameters: inputStream - String of the whole inputStream's contents throws: IOException - |
readFullyToFile | public static long readFullyToFile(InputStream is, File toFile, byte[] buffer) throws IOException(Code) | | Read the entire stream to EOF into the passed file.
Closes is when done or if an exception.
Parameters: is - Stream to read. Parameters: toFile - File to read into . Parameters: buffer - Buffer to use reading. Count of bytes read. throws: IOException - |
serializeToByteArray | public static byte[] serializeToByteArray(Object object)(Code) | | Utility method to serialize Object to byte[].
Parameters: object - Object to be serialized byte[] serialized form |
serializeToFile | public static void serializeToFile(Object object, File file) throws IOException(Code) | | Utility method to serialize an object to the given File.
Parameters: object - Object to serialize Parameters: file - File to receive serialized copy throws: IOException - |
wrapAsIOException | public static IOException wrapAsIOException(Throwable e)(Code) | | Wrap generic Throwable as a checked IOException
Parameters: e - wrapped exception IOException |
|
|