|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.cocoon.util.IOUtils
A collection of File
, URL
and filename
utility methods
Constructor Summary | |
IOUtils()
|
Method Summary | |
static java.lang.String |
baseName(java.lang.String filename)
Strip a filename of its last extension (the portion immediately following the last dot character, if any) |
static java.lang.Object |
bytesToObject(byte[] bytes)
Returns a object from the given byte array. |
static java.io.File |
createFile(java.io.File destDir,
java.lang.String filename)
Return a file with the given filename creating the necessary directories if not present. |
static java.lang.Object |
deserializeObject(java.io.File file)
This method deserializes an object from an input stream. |
static java.lang.String |
deserializeString(java.io.File file)
Load a text file contents as a String |
static java.lang.String |
fileComponent(java.lang.String filename)
Remove path information from a filename returning only its file component |
static java.lang.String |
getContextFilePath(java.lang.String directoryPath,
java.lang.String filePath)
Return the path within a base directory |
static java.lang.String |
getFullFilename(java.io.File file)
Get the complete filename corresponding to a (typically relative) File .
|
static java.lang.String |
normalizedFilename(java.lang.String filename)
Return a modified filename suitable for replicating directory structures below the store's base directory. |
static byte[] |
objectToBytes(java.lang.Object object)
Returns a byte array from the given object. |
static java.lang.String |
pathComponent(java.lang.String filename)
Remove file information from a filename returning only its path component |
static void |
serializeObject(java.io.File file,
java.lang.Object object)
This method serializes an object to an output stream. |
static void |
serializeString(java.io.File file,
java.lang.String string)
Dump a String to a text file. |
static void |
serializeString(java.io.File file,
java.lang.String string,
java.lang.String encoding)
Dump a String to a text file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public IOUtils()
Method Detail |
public static void serializeString(java.io.File file, java.lang.String string) throws java.io.IOException
String
to a text file.file
- The output filestring
- The string to be dumpedjava.io.IOException
- IO Errorpublic static void serializeString(java.io.File file, java.lang.String string, java.lang.String encoding) throws java.io.IOException
String
to a text file.file
- The output filestring
- The string to be dumpedencoding
- The encoding for the output file or null for default platform encodingjava.io.IOException
- IO Errorpublic static java.lang.String deserializeString(java.io.File file) throws java.io.IOException
String.
This method does not perform enconding conversions
- Parameters:
file
- The input file- Returns:
- The file contents as a
String
- Throws:
java.io.IOException
- IO Error
serializeObject
public static void serializeObject(java.io.File file,
java.lang.Object object)
throws java.io.IOException
- This method serializes an object to an output stream.
- Parameters:
file
- The output fileobject
- The object to be serialized- Throws:
java.io.IOException
- IOError
deserializeObject
public static java.lang.Object deserializeObject(java.io.File file)
throws java.io.IOException,
java.lang.ClassNotFoundException
- This method deserializes an object from an input stream.
- Parameters:
file
- The input file- Returns:
- The deserialized object
- Throws:
java.io.IOException
- IOError
normalizedFilename
public static java.lang.String normalizedFilename(java.lang.String filename)
- Return a modified filename suitable for replicating directory
structures below the store's base directory. The following
conversions are performed:
- Path separators are converted to regular directory names
- File path components are transliterated to make them valid (?)
programming language identifiers. This transformation may well
generate collisions for unusual filenames.
- Returns:
- The transformed filename
pathComponent
public static java.lang.String pathComponent(java.lang.String filename)
- Remove file information from a filename returning only its path
component
- Parameters:
filename
- The filename- Returns:
- The path information
fileComponent
public static java.lang.String fileComponent(java.lang.String filename)
- Remove path information from a filename returning only its file
component
- Parameters:
filename
- The filename- Returns:
- The filename sans path information
baseName
public static java.lang.String baseName(java.lang.String filename)
- Strip a filename of its last extension (the portion
immediately following the last dot character, if any)
- Parameters:
filename
- The filename- Returns:
- The filename sans extension
getFullFilename
public static java.lang.String getFullFilename(java.io.File file)
- Get the complete filename corresponding to a (typically relative)
File
.
This method accounts for the possibility of an error in getting
the filename's canonical path, returning the io/error-safe
absolute form instead
- Parameters:
file
- The file- Returns:
- The file's absolute filename
getContextFilePath
public static java.lang.String getContextFilePath(java.lang.String directoryPath,
java.lang.String filePath)
- Return the path within a base directory
createFile
public static java.io.File createFile(java.io.File destDir,
java.lang.String filename)
- Return a file with the given filename creating the necessary
directories if not present.
- Parameters:
filename
- The file- Returns:
- The created File instance
objectToBytes
public static byte[] objectToBytes(java.lang.Object object)
throws java.io.IOException
- Returns a byte array from the given object.
- Parameters:
object
- to convert- Returns:
- byte array from the object
bytesToObject
public static java.lang.Object bytesToObject(byte[] bytes)
throws java.io.IOException,
java.lang.ClassNotFoundException
- Returns a object from the given byte array.
- Parameters:
bytes
- array to convert- Returns:
- object
Overview
Package
Class
Tree
Deprecated
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright � 1999-2002 Apache Software Foundation. All Rights Reserved.