|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.archive.util.IoUtils
public class IoUtils
I/O Utility methods.
Field Summary | |
---|---|
protected static java.util.logging.Logger |
logger
|
Constructor Summary | |
---|---|
IoUtils()
|
Method Summary | |
---|---|
static java.lang.Object |
deserializeFromByteArray(byte[] in)
Utility method to deserialize Object from byte[]. |
static java.lang.Object |
deserializeFromFile(java.io.File file)
Utility method to deserialize an Object from given File. |
static float |
encodingMaxBytesPerChar(java.lang.String encoding)
Return the maximum number of bytes per character in the named encoding, or 0 if encoding is invalid or unsupported. |
static java.io.File |
ensureWriteableDirectory(java.io.File dir)
Ensure writeable directory. |
static java.util.List |
ensureWriteableDirectory(java.util.List<java.io.File> dirs)
Ensure writeable directories. |
static java.io.File |
ensureWriteableDirectory(java.lang.String dir)
Ensure writeable directory. |
static java.lang.String |
getClasspathPath(java.io.File file)
|
static void |
readFully(java.io.InputStream input,
byte[] buf)
|
static java.lang.String |
readFullyAsString(java.io.InputStream inputStream)
Read the entire stream to EOF, returning what's read as a String. |
static void |
readFullyToFile(java.io.InputStream is,
java.io.File toFile)
Read the entire stream to EOF into the passed file. |
static long |
readFullyToFile(java.io.InputStream is,
java.io.File toFile,
byte[] buffer)
Read the entire stream to EOF into the passed file. |
static byte[] |
serializeToByteArray(java.lang.Object object)
Utility method to serialize Object to byte[]. |
static void |
serializeToFile(java.lang.Object object,
java.io.File file)
Utility method to serialize an object to the given File. |
static java.io.IOException |
wrapAsIOException(java.lang.Throwable e)
Wrap generic Throwable as a checked IOException |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.util.logging.Logger logger
Constructor Detail |
---|
public IoUtils()
Method Detail |
---|
public static java.lang.String getClasspathPath(java.io.File file)
file
- File to operate on.
public static java.io.File ensureWriteableDirectory(java.lang.String dir) throws java.io.IOException
dir
- Directory to test for exitence and is writeable.
dir
.
java.io.IOException
- If passed directory does not exist and is not
createable, or directory is not writeable or is not a directory.public static java.util.List ensureWriteableDirectory(java.util.List<java.io.File> dirs) throws java.io.IOException
dirs
- List of Files to test.
dirs
.
java.io.IOException
- If passed directory does not exist and is not
createable, or directory is not writeable or is not a directory.public static java.io.File ensureWriteableDirectory(java.io.File dir) throws java.io.IOException
dir
- Directory to test for exitence and is writeable.
dir
.
java.io.IOException
- If passed directory does not exist and is not
createable, or directory is not writeable or is not a directory.public static java.lang.String readFullyAsString(java.io.InputStream inputStream) throws java.io.IOException
inputStream
-
java.io.IOException
public static void readFullyToFile(java.io.InputStream is, java.io.File toFile) throws java.io.IOException
is
- toFile
- File to read into .
java.io.IOException
java.io.IOException
public static long readFullyToFile(java.io.InputStream is, java.io.File toFile, byte[] buffer) throws java.io.IOException
is
when done or if an exception.
is
- Stream to read.toFile
- File to read into .buffer
- Buffer to use reading.
java.io.IOException
public static java.io.IOException wrapAsIOException(java.lang.Throwable e)
e
- wrapped exception
public static void readFully(java.io.InputStream input, byte[] buf) throws java.io.IOException
java.io.IOException
public static float encodingMaxBytesPerChar(java.lang.String encoding)
encoding
- Encoding to consider. For now, should be java
canonical name for the encoding.
public static void serializeToFile(java.lang.Object object, java.io.File file) throws java.io.IOException
object
- Object to serializefile
- File to receive serialized copy
java.io.IOException
public static java.lang.Object deserializeFromFile(java.io.File file) throws java.io.IOException
file
- File source
java.io.IOException
public static byte[] serializeToByteArray(java.lang.Object object)
object
- Object to be serialized
public static java.lang.Object deserializeFromByteArray(byte[] in)
in
- byte[] source
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |