org.apache.activemq.apollo.util
Class IOHelper

java.lang.Object
  extended by org.apache.activemq.apollo.util.IOHelper

public final class IOHelper
extends java.lang.Object


Nested Class Summary
static interface IOHelper.IOStrategy
           
 
Field Summary
protected static int MAX_DIR_NAME_LENGTH
           
protected static int MAX_FILE_NAME_LENGTH
           
 
Method Summary
static void close(java.io.InputStream in)
           
static void close(java.io.OutputStream out)
           
static void close(java.io.Writer out)
           
static void copyFile(java.io.File src, java.io.File dest)
           
static void copyInputStream(java.io.InputStream in, java.io.OutputStream out)
           
static boolean deleteChildren(java.io.File parent)
           
static boolean deleteFile(java.io.File fileToDelete)
           
static CLibrary getCLibrary()
           
static java.lang.String getDefaultDataDirectory()
           
static java.lang.String getDefaultDirectoryPrefix()
          Allows a system property to be used to overload the default data directory which can be useful for forcing the test cases to use a target/ prefix
static java.lang.String getDefaultStoreDirectory()
           
static void mkdirs(java.io.File dir)
           
static void moveFile(java.io.File src, java.io.File targetDirectory)
           
static byte[] readBytes(java.io.File path)
           
static byte[] readBytes(java.io.InputStream in)
           
static java.lang.String readText(java.io.File path)
           
static java.lang.String readText(java.io.File path, java.lang.String encoding)
           
static java.lang.String readText(java.io.InputStream in)
           
static java.lang.String readText(java.io.InputStream in, java.lang.String encoding)
           
static void sync(java.io.FileDescriptor fd)
           
static java.lang.String toFileSystemDirectorySafeName(java.lang.String name)
          Converts any string into a string that is safe to use as a file name.
static java.lang.String toFileSystemSafeName(java.lang.String name)
           
static java.lang.String toFileSystemSafeName(java.lang.String name, boolean dirSeparators, int maxFileLength)
          Converts any string into a string that is safe to use as a file name.
static void writeBinaryFile(java.io.File path, byte[] contents)
           
static void writeText(java.io.File path, java.lang.String text)
           
static void writeText(java.io.File path, java.lang.String text, java.lang.String encoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_DIR_NAME_LENGTH

protected static final int MAX_DIR_NAME_LENGTH

MAX_FILE_NAME_LENGTH

protected static final int MAX_FILE_NAME_LENGTH
Method Detail

getDefaultDataDirectory

public static java.lang.String getDefaultDataDirectory()

getDefaultStoreDirectory

public static java.lang.String getDefaultStoreDirectory()

getDefaultDirectoryPrefix

public static java.lang.String getDefaultDirectoryPrefix()
Allows a system property to be used to overload the default data directory which can be useful for forcing the test cases to use a target/ prefix


toFileSystemDirectorySafeName

public static java.lang.String toFileSystemDirectorySafeName(java.lang.String name)
Converts any string into a string that is safe to use as a file name. The result will only include ascii characters and numbers, and the "-","_", and "." characters.

Parameters:
name -
Returns:

toFileSystemSafeName

public static java.lang.String toFileSystemSafeName(java.lang.String name)

toFileSystemSafeName

public static java.lang.String toFileSystemSafeName(java.lang.String name,
                                                    boolean dirSeparators,
                                                    int maxFileLength)
Converts any string into a string that is safe to use as a file name. The result will only include ascii characters and numbers, and the "-","_", and "." characters.

Parameters:
name -
dirSeparators -
maxFileLength -
Returns:

deleteFile

public static boolean deleteFile(java.io.File fileToDelete)

deleteChildren

public static boolean deleteChildren(java.io.File parent)

moveFile

public static void moveFile(java.io.File src,
                            java.io.File targetDirectory)
                     throws java.io.IOException
Throws:
java.io.IOException

copyFile

public static void copyFile(java.io.File src,
                            java.io.File dest)
                     throws java.io.IOException
Throws:
java.io.IOException

readText

public static java.lang.String readText(java.io.File path)
                                 throws java.io.IOException
Throws:
java.io.IOException

readText

public static java.lang.String readText(java.io.File path,
                                        java.lang.String encoding)
                                 throws java.io.IOException
Throws:
java.io.IOException

readText

public static java.lang.String readText(java.io.InputStream in)
                                 throws java.io.IOException
Throws:
java.io.IOException

readText

public static java.lang.String readText(java.io.InputStream in,
                                        java.lang.String encoding)
                                 throws java.io.IOException
Throws:
java.io.IOException

readBytes

public static byte[] readBytes(java.io.File path)
                        throws java.io.IOException
Throws:
java.io.IOException

readBytes

public static byte[] readBytes(java.io.InputStream in)
                        throws java.io.IOException
Throws:
java.io.IOException

writeText

public static void writeText(java.io.File path,
                             java.lang.String text)
                      throws java.io.IOException
Throws:
java.io.IOException

writeText

public static void writeText(java.io.File path,
                             java.lang.String text,
                             java.lang.String encoding)
                      throws java.io.IOException
Throws:
java.io.IOException

writeBinaryFile

public static void writeBinaryFile(java.io.File path,
                                   byte[] contents)
                            throws java.io.IOException
Throws:
java.io.IOException

copyInputStream

public static void copyInputStream(java.io.InputStream in,
                                   java.io.OutputStream out)
                            throws java.io.IOException
Throws:
java.io.IOException

close

public static void close(java.io.Writer out)

close

public static void close(java.io.OutputStream out)

close

public static void close(java.io.InputStream in)

mkdirs

public static void mkdirs(java.io.File dir)
                   throws java.io.IOException
Throws:
java.io.IOException

getCLibrary

public static CLibrary getCLibrary()
                            throws java.lang.ClassNotFoundException,
                                   java.lang.IllegalAccessException,
                                   java.lang.NoSuchFieldException
Throws:
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.NoSuchFieldException

sync

public static void sync(java.io.FileDescriptor fd)
                 throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2005-2011 The Apache Software Foundation. All Rights Reserved.