org.melati.util
Class FileUtils

Package class diagram package FileUtils
java.lang.Object
  extended by org.melati.util.FileUtils

public final class FileUtils
extends Object

An assortment of useful operations on Files.


Method Summary
static void makeExecutable(File file)
          Mark a file as executable.
static File withUniqueName(File file)
          Returns a File in the given directory which does not already exist.
static File writeFile(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 File withUniqueName(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 File writeFile(File file,
                             byte[] data)
                      throws 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:
IOException

makeExecutable

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

Throws:
IOException


Copyright © 2000-2010 PanEris. All Rights Reserved.