org.gerhardb.lib.util
Class FileUtil

java.lang.Object
  extended byorg.gerhardb.lib.util.FileUtil

public class FileUtil
extends java.lang.Object


Method Summary
static java.lang.String checkDirectory(java.lang.String dirName)
          Returns null if directory not found.
static void concatFiles(java.io.File newFile, java.io.File[] concat)
          Concatenates a list of files to a new file.
static void copyFile(java.io.File toDir, java.io.File copyThis)
          Physically copy a file to a different directory.
static boolean copyFile(java.io.File toDir, java.io.File copyThis, java.awt.Component onTopOf)
          Physically copy a file to a different directory.
static boolean copyFileLog(java.io.File toDir, java.io.File copyThis)
          Physically copy a file to a different directory.
static java.lang.String fileNameNoExtension(java.lang.String oldName)
          Removes the file name extension.
static java.lang.String getStringFromFile(java.io.File file)
          Gets a string (for example an XML string) from a file.
static void main(java.lang.String[] args)
           
static boolean moveFile(java.io.File toDir, java.io.File moveThis, java.awt.Component onTopOf)
          Physically move a file to a different directory, WITH on screen error reporting.
static void moveFile(java.io.File toDir, java.io.File moveThis, java.lang.StringBuffer report)
          Physically move a file to a different directory.
static java.lang.String safeValidateDirectory(java.lang.String dirName)
          Check for a direcotry with no errors reported.
static java.lang.String validateDirectory(java.lang.String dirName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fileNameNoExtension

public static java.lang.String fileNameNoExtension(java.lang.String oldName)
Removes the file name extension.

The file name extension is defined as the last dot something. Examples:
foo.jpg ==> foo foo.bar.jpg ==> foo.bar foo.bar.not.jpg ==> foo.bar.not sometextfile.txt ==> sometextfile

Returns:
file name without extension

copyFile

public static void copyFile(java.io.File toDir,
                            java.io.File copyThis)
                     throws TargetFileExistsException,
                            java.io.FileNotFoundException,
                            java.io.IOException
Physically copy a file to a different directory. All problems are handled here.

Throws:
TargetFileExistsException
java.io.FileNotFoundException
java.io.IOException

moveFile

public static void moveFile(java.io.File toDir,
                            java.io.File moveThis,
                            java.lang.StringBuffer report)
                     throws java.lang.Exception
Physically move a file to a different directory.

Throws:
TargetFileExistsException
java.lang.Exception

concatFiles

public static void concatFiles(java.io.File newFile,
                               java.io.File[] concat)
                        throws TargetFileExistsException,
                               java.io.FileNotFoundException,
                               java.io.IOException
Concatenates a list of files to a new file. Will destroy the new file so be sure the new file is NOT in the list of files to be concatentated.

Throws:
TargetFileExistsException
java.io.FileNotFoundException
java.io.IOException

copyFileLog

public static boolean copyFileLog(java.io.File toDir,
                                  java.io.File copyThis)
Physically copy a file to a different directory. All problems are handled here.


copyFile

public static boolean copyFile(java.io.File toDir,
                               java.io.File copyThis,
                               java.awt.Component onTopOf)
Physically copy a file to a different directory. All problems are handled here.


moveFile

public static boolean moveFile(java.io.File toDir,
                               java.io.File moveThis,
                               java.awt.Component onTopOf)
Physically move a file to a different directory, WITH on screen error reporting.


safeValidateDirectory

public static java.lang.String safeValidateDirectory(java.lang.String dirName)
Check for a direcotry with no errors reported.

Parameters:
dirName -
Returns:
null for any problems

validateDirectory

public static java.lang.String validateDirectory(java.lang.String dirName)
                                          throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

checkDirectory

public static java.lang.String checkDirectory(java.lang.String dirName)
Returns null if directory not found.

Parameters:
dirName -
Returns:
name of directory if it exists.

getStringFromFile

public static java.lang.String getStringFromFile(java.io.File file)
                                          throws java.io.FileNotFoundException,
                                                 java.io.IOException
Gets a string (for example an XML string) from a file.

Parameters:
file - The file to read.
Returns:
contents The contents of the file as a String.
Throws:
java.io.FileNotFoundException
java.io.IOException

main

public static void main(java.lang.String[] args)


Copyright © 2002 Gerhard Beck. All rights reserved. Subject to GPL.