net.sf.zig_project.gpl.common.io
Class Filer

java.lang.Object
  extended bynet.sf.zig_project.gpl.common.io.Filer

public abstract class Filer
extends Object

Provides a set of common routines for dealing with files managed by the local file system.

Version:
November 22, 2004
Author:
Frank Ziglar

Constructor Summary
Filer()
           
 
Method Summary
static void copy(File source, File target)
          Duplicates a file.
static void copy(File source, File target, byte[] buffer)
          Duplicates a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Filer

public Filer()
Method Detail

copy

public static void copy(File source,
                        File target)
                 throws IOException
Duplicates a file.

Throws:
IOException
See Also:
copy(File, File, byte[])

copy

public static void copy(File source,
                        File target,
                        byte[] buffer)
                 throws IOException
Duplicates a file.
  1. If source does not exist, a FileNotFoundException is thrown
  2. If target already exists, then
    1. If target is a directory, then the new file will reside within the target, retaining it's origional name.
    2. If target still exists (after possibly applying the previous rule), then an exception will be raised to avoid overwriting the existing target file
  3. If source is a directory, then
    1. Target is created as a new directory
    2. Each file from the source directory is copied into the target directory, preserving their names within their parent directory.
    3. The contents are not necessarily copied to the target in order. It is assumed the filesystem will organized the files by name, or that the order of the files is not relevant.
      1. Otherwise, source is assumed to be a data file, and a new file is created with the target name, containing a binary duplicate of the source.

      Throws:
      IOException