org.gerhardb.lib.util
Class FileUtil

java.lang.Object
  extended by org.gerhardb.lib.util.FileUtil

public class FileUtil
extends java.lang.Object


Field Summary
static java.lang.String NEWLINE
           
static java.lang.String SPACE
           
static java.lang.String SPACE_5
           
static java.lang.String SYS_NEWLINE
           
 
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, javax.swing.BoundedRangeModel range, StopCheck check)
          Concatenates a list of files to a new file.
static void copyFile(java.io.File toFile, java.io.File copyThis)
          Physically copy a file to a different name.
static void copyFileToDir(java.io.File toDir, java.io.File copyThis)
          Physically copy a file to a different directory.
static boolean copyFileToDir(java.io.File toDir, java.io.File copyThis, java.awt.Component onTopOf)
          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 getExtension(java.lang.String name)
          Returns 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 java.lang.String lookupDir(java.lang.String msg, java.lang.String priorDir, java.awt.Component comp)
           
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, EzLogger logger, boolean makeNewName)
          Physically move a file to a different directory.
static void moveFile(java.lang.String toDir, java.io.File moveThis)
          Optimized for where called from...
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
 

Field Detail

SPACE

public static final java.lang.String SPACE
See Also:
Constant Field Values

SPACE_5

public static final java.lang.String SPACE_5
See Also:
Constant Field Values

NEWLINE

public static final java.lang.String NEWLINE
See Also:
Constant Field Values

SYS_NEWLINE

public static final java.lang.String SYS_NEWLINE
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

getExtension

public static java.lang.String getExtension(java.lang.String name)
Returns the file name extension.

The file name extension is defined as the last dot something. Returns null if there is no dot. Examples:
foo.jpg ==> jpg

Returns:
fextension

copyFile

public static void copyFile(java.io.File toFile,
                            java.io.File copyThis)
                     throws TargetFileExistsException,
                            java.io.FileNotFoundException,
                            java.io.IOException
Physically copy a file to a different name.

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

copyFileToDir

public static void copyFileToDir(java.io.File toDir,
                                 java.io.File copyThis)
                          throws TargetFileExistsException,
                                 java.io.FileNotFoundException,
                                 java.io.IOException
Physically copy a file to a different directory.

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

moveFile

public static void moveFile(java.lang.String toDir,
                            java.io.File moveThis)
                     throws java.lang.Exception
Optimized for where called from...

Parameters:
toDir -
moveThis -
Throws:
java.lang.Exception

moveFile

public static void moveFile(java.io.File toDir,
                            java.io.File moveThis,
                            java.lang.StringBuffer report,
                            EzLogger logger,
                            boolean makeNewName)
                     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,
                               javax.swing.BoundedRangeModel range,
                               StopCheck check)
                        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

copyFileToDir

public static boolean copyFileToDir(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

lookupDir

public static java.lang.String lookupDir(java.lang.String msg,
                                         java.lang.String priorDir,
                                         java.awt.Component comp)

main

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


Copyright ? 2007 Gerhard Beck. All rights reserved. Subject to GPL.