nl.toolforge.core.util.file
Class MyFileUtils

java.lang.Object
  extended bynl.toolforge.core.util.file.MyFileUtils

public final class MyFileUtils
extends java.lang.Object

File utilities. Stuff that is not implemented by org.apache.commons.io.FileUtils.

Version:
$Id:
Author:
D.A. Smedes, A. Mooy

Constructor Summary
MyFileUtils()
           
 
Method Summary
static java.io.File createTempDirectory()
          Creates a temporary directory with some random positive long as its name.
static java.io.File getSystemTempDirectory()
           
static void makeReadOnly(java.io.File dir)
          Makes all files in dir and all its subdirectories read-only.
static void makeWriteable(java.io.File target, boolean recurse)
          Makes the specified file or directory writeable.
static void writeFile(java.io.File dir, java.io.File fileRef, java.io.File newFileName, java.lang.ClassLoader classLoader)
          Writes fileRef to dir as newFileRef.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyFileUtils

public MyFileUtils()
Method Detail

getSystemTempDirectory

public static java.io.File getSystemTempDirectory()
Returns:
A File instance pointing to the system temp dir (specified in the "java.io.tmpdir" system property).

createTempDirectory

public static java.io.File createTempDirectory()
                                        throws java.io.IOException
Creates a temporary directory with some random positive long as its name.

Returns:
A File reference to the temporary directory.
Throws:
java.io.IOException - When some IO error occurred.

makeWriteable

public static void makeWriteable(java.io.File target,
                                 boolean recurse)
                          throws java.io.IOException,
                                 java.lang.InterruptedException
Makes the specified file or directory writeable. If the recurse parameter is true and the specified target is a directory, this method will recurse into subdirectories.

Parameters:
target - File or directory to make writeable.
recurse -
Throws:
java.io.IOException
java.lang.InterruptedException

makeReadOnly

public static void makeReadOnly(java.io.File dir)
Makes all files in dir and all its subdirectories read-only. Uses the Ant DirectoryScanner.

Parameters:
dir - Starting directory.

writeFile

public static void writeFile(java.io.File dir,
                             java.io.File fileRef,
                             java.io.File newFileName,
                             java.lang.ClassLoader classLoader)
                      throws java.io.IOException
Writes fileRef to dir as newFileRef. fileRef should be available in the classpath of classLoader.

Parameters:
dir - The directory to write to
fileRef - The original filename (path)
newFileName - The new filename
classLoader - The class loader that contains fileRef
Throws:
java.io.IOException


Copyright © 2002-2006 Toolforge. All Rights Reserved.