org.apache.cocoon.util
Class IOUtils

java.lang.Object
  extended byorg.apache.cocoon.util.IOUtils

public class IOUtils
extends Object

A collection of File, URL and filename utility methods

Version:
$Id: IOUtils.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Constructor Summary
IOUtils()
           
 
Method Summary
static String baseName(String filename)
          Deprecated. To be removed in cocoon 2.3
static Object bytesToObject(byte[] bytes)
          Deprecated. To be removed in cocoon 2.3
static File createFile(File destDir, String filename)
          Return a file with the given filename creating the necessary directories if not present.
static Object deserializeObject(File file)
          Deprecated. To be removed in cocoon 2.3
static String deserializeString(File file)
          Load a text file contents as a String.
static String fileComponent(String filename)
          Deprecated. To be removed in cocoon 2.3
static String getContextFilePath(String directoryPath, String filePath)
          Return the path within a base directory
static String getFullFilename(File file)
          Get the complete filename corresponding to a (typically relative) File.
static String normalizedFilename(String filename)
          Return a modified filename suitable for replicating directory structures below the store's base directory.
static byte[] objectToBytes(Object object)
          Deprecated. To be removed in cocoon 2.3
static String pathComponent(String filename)
          Deprecated. To be removed in cocoon 2.3
static void serializeObject(File file, Object object)
          Deprecated. To be removed in cocoon 2.3
static void serializeString(File file, String string)
          Deprecated. To be removed in cocoon 2.3
static void serializeString(File file, String string, String encoding)
          Deprecated. To be removed in cocoon 2.3
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOUtils

public IOUtils()
Method Detail

serializeString

public static void serializeString(File file,
                                   String string)
                            throws IOException
Deprecated. To be removed in cocoon 2.3

Dump a String to a text file.

Parameters:
file - The output file
string - The string to be dumped
Throws:
IOException - IO Error

serializeString

public static void serializeString(File file,
                                   String string,
                                   String encoding)
                            throws IOException
Deprecated. To be removed in cocoon 2.3

Dump a String to a text file.

Parameters:
file - The output file
string - The string to be dumped
encoding - The encoding for the output file or null for default platform encoding
Throws:
IOException - IO Error

deserializeString

public static String deserializeString(File file)
                                throws IOException
Load a text file contents as a String. This method does not perform enconding conversions

Parameters:
file - The input file
Returns:
The file contents as a String
Throws:
IOException - IO Error

serializeObject

public static void serializeObject(File file,
                                   Object object)
                            throws IOException
Deprecated. To be removed in cocoon 2.3

This method serializes an object to an output stream.

Parameters:
file - The output file
object - The object to be serialized
Throws:
IOException - IOError

deserializeObject

public static Object deserializeObject(File file)
                                throws IOException,
                                       ClassNotFoundException
Deprecated. To be removed in cocoon 2.3

This method deserializes an object from an input stream.

Parameters:
file - The input file
Returns:
The deserialized object
Throws:
IOException - IOError
ClassNotFoundException

normalizedFilename

public static String normalizedFilename(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 String pathComponent(String filename)
Deprecated. To be removed in cocoon 2.3

Remove file information from a filename returning only its path component

Parameters:
filename - The filename
Returns:
The path information

fileComponent

public static String fileComponent(String filename)
Deprecated. To be removed in cocoon 2.3

Remove path information from a filename returning only its file component

Parameters:
filename - The filename
Returns:
The filename sans path information

baseName

public static String baseName(String filename)
Deprecated. To be removed in cocoon 2.3

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 String getFullFilename(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 String getContextFilePath(String directoryPath,
                                        String filePath)
Return the path within a base directory


createFile

public static File createFile(File destDir,
                              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(Object object)
                            throws IOException
Deprecated. To be removed in cocoon 2.3

Returns a byte array from the given object.

Parameters:
object - to convert
Returns:
byte array from the object
Throws:
IOException

bytesToObject

public static Object bytesToObject(byte[] bytes)
                            throws IOException,
                                   ClassNotFoundException
Deprecated. To be removed in cocoon 2.3

Returns a object from the given byte array.

Parameters:
bytes - array to convert
Returns:
object
Throws:
IOException
ClassNotFoundException


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.