org.af.commons.io
Class FileTools

java.lang.Object
  extended by org.af.commons.io.FileTools

public class FileTools
extends Object

This class provides miscellaneous static methods for handling files.


Constructor Summary
FileTools()
           
 
Method Summary
static String getBaseName(File file)
          Returns the filename without last suffix.
static String readFileAsString(File file)
           
static File selectFile(Component comp, File prevFile, int fileSelectionMode)
          Opens a JFileChooser for selecting a file or directory.
static File selectFile(Component comp, int fileSelectionMode)
          Opens a JFileChooser for selecting a file or directory.
static File selectFile(Component comp, String prevFile, int fileSelectionMode)
          Opens a JFileChooser for selecting a file or directory.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTools

public FileTools()
Method Detail

getBaseName

public static String getBaseName(File file)
Returns the filename without last suffix. Example: getBaseName("test.txt") returns "test".

Returns:
filename without last suffix.

selectFile

public static File selectFile(Component comp,
                              String prevFile,
                              int fileSelectionMode)
Opens a JFileChooser for selecting a file or directory.

Parameters:
comp - the parent component of the dialog, can be null;
prevFile - previously chosen file
fileSelectionMode - from JFileChooser
Returns:
the selected file or null if no file was selected

selectFile

public static File selectFile(Component comp,
                              int fileSelectionMode)
Opens a JFileChooser for selecting a file or directory.

Parameters:
comp - the parent component of the dialog, can be null;
fileSelectionMode - from JFileChooser
Returns:
the selected file or null if no file was selected

selectFile

public static File selectFile(Component comp,
                              File prevFile,
                              int fileSelectionMode)
Opens a JFileChooser for selecting a file or directory.

Parameters:
comp - the parent component of the dialog, can be null;
prevFile - previously chosen file
fileSelectionMode - from JFileChooser
Returns:
the selected file or null if no file was selected

readFileAsString

public static String readFileAsString(File file)
                               throws IOException
Throws:
IOException