org.melati.util
Class FileUtils

java.lang.Object
  extended by org.melati.util.FileUtils

public final class FileUtils
extends java.lang.Object

An assortment of useful operations on Files.


Method Summary
static void makeExecutable(java.io.File file)
          Mark a file as executable.
static java.io.File withUniqueName(java.io.File file)
          Returns a File in the given directory which does not already exist.
static java.io.File writeFile(java.io.File file, byte[] data)
          Write a byte array to a given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

withUniqueName

public static java.io.File withUniqueName(java.io.File file)
Returns a File in the given directory which does not already exist. This file is found by starting with the given filename. If a file of this name already exists we put 0 then 1,2,... before the extension until we find one that does not exists.

For instance, if newfile.txt exists then we check newfile0.txt, newfile1.txt, ... until we find a new filename.

Returns:
a new File whose name has been made unique

writeFile

public static java.io.File writeFile(java.io.File file,
                                     byte[] data)
                              throws java.io.IOException
Write a byte array to a given file.

Parameters:
file - file to write to
data - to write to file
Returns:
File with data written to it
Throws:
java.io.IOException

makeExecutable

public static void makeExecutable(java.io.File file)
                           throws java.io.IOException
Mark a file as executable. Does chmod +x file on Unix, else does nothing.

Throws:
java.io.IOException


Copyright © 2000-2008 PanEris. All Rights Reserved.