net.grelf.grip
Class FileIO

java.lang.Object
  extended by net.grelf.grip.FileIO

public class FileIO
extends java.lang.Object

Various useful static methods for file handling. This class cannot be instantiated. It has a javax.swing.JFileChooser object so that successive calls to methods here keep track of the last directory used, for the user's convenience.


Method Summary
static void copyFile(java.lang.String srcPath, java.lang.String dstPath)
          Copy any file.
static javax.swing.filechooser.FileFilter getCurrentFilter()
           
static java.lang.String getExtension(java.lang.String filename)
          Get the file extension, including the dot.
static boolean isXmlFile(java.lang.String filePath)
          Reads the first 5 characters of the given file to see whether they are >?xml
New 9.12.3
static java.lang.String removeExtension(java.lang.String filename)
          Remove the file extension, including the dot.
static java.lang.String selectInputFile(java.lang.String title)
          Returns null if user leaves the file selection dialogue by the cancel button.
static java.lang.String selectInputFile(java.lang.String title, java.lang.String folderName)
          Returns null if user leaves the file selection dialogue by the cancel button.
static java.lang.String selectInputFile(java.lang.String title, java.lang.String folderName, javax.swing.filechooser.FileFilter[] filters)
          Returns null if user leaves the file selection dialogue by the cancel button.
static java.lang.String selectInputFile(java.lang.String title, java.lang.String folderName, javax.swing.filechooser.FileFilter[] filters, java.lang.String initialFileName)
          Returns null if user leaves the file selection dialogue by the cancel button.
static java.io.File[] selectInputFiles(java.lang.String title)
          Returns null if user leaves the file selection dialogue by the cancel button.
static java.io.File[] selectInputFiles(java.lang.String title, java.lang.String folderName)
          Returns null if user leaves the file selection dialogue by the cancel button.
static java.io.File[] selectInputFiles(java.lang.String title, java.lang.String folderName, javax.swing.filechooser.FileFilter[] filters)
          Returns null if user leaves the file selection dialogue by the cancel button.
static java.lang.String selectOutputFile(java.lang.String title)
          Returns null if user leaves the file selection dialogue by the cancel button.
static java.lang.String selectOutputFile(java.lang.String title, java.lang.String folderName)
          Returns null if user leaves the file selection dialogue by the cancel button.
static java.lang.String selectOutputFile(java.lang.String title, java.lang.String folderName, javax.swing.filechooser.FileFilter[] filters)
          Returns null if user leaves the file selection dialogue by the cancel button.
static java.lang.String selectOutputFile(java.lang.String title, java.lang.String folderName, javax.swing.filechooser.FileFilter[] filters, java.lang.String initialFileName)
          Returns null if user leaves the file selection dialogue by the cancel button.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copyFile

public static void copyFile(java.lang.String srcPath,
                            java.lang.String dstPath)
                     throws java.io.IOException
Copy any file.

Throws:
java.io.IOException

getExtension

public static java.lang.String getExtension(java.lang.String filename)
Get the file extension, including the dot. Returns an empty string if there is no dot.


isXmlFile

public static boolean isXmlFile(java.lang.String filePath)
Reads the first 5 characters of the given file to see whether they are >?xml
New 9.12.3


removeExtension

public static java.lang.String removeExtension(java.lang.String filename)
Remove the file extension, including the dot.


selectInputFile

public static java.lang.String selectInputFile(java.lang.String title)
Returns null if user leaves the file selection dialogue by the cancel button.


selectInputFile

public static java.lang.String selectInputFile(java.lang.String title,
                                               java.lang.String folderName)
Returns null if user leaves the file selection dialogue by the cancel button.


selectInputFile

public static java.lang.String selectInputFile(java.lang.String title,
                                               java.lang.String folderName,
                                               javax.swing.filechooser.FileFilter[] filters)
Returns null if user leaves the file selection dialogue by the cancel button.


selectInputFile

public static java.lang.String selectInputFile(java.lang.String title,
                                               java.lang.String folderName,
                                               javax.swing.filechooser.FileFilter[] filters,
                                               java.lang.String initialFileName)
Returns null if user leaves the file selection dialogue by the cancel button.


selectInputFiles

public static java.io.File[] selectInputFiles(java.lang.String title)
Returns null if user leaves the file selection dialogue by the cancel button.


selectInputFiles

public static java.io.File[] selectInputFiles(java.lang.String title,
                                              java.lang.String folderName)
Returns null if user leaves the file selection dialogue by the cancel button.


selectInputFiles

public static java.io.File[] selectInputFiles(java.lang.String title,
                                              java.lang.String folderName,
                                              javax.swing.filechooser.FileFilter[] filters)
Returns null if user leaves the file selection dialogue by the cancel button.


selectOutputFile

public static java.lang.String selectOutputFile(java.lang.String title)
Returns null if user leaves the file selection dialogue by the cancel button.


selectOutputFile

public static java.lang.String selectOutputFile(java.lang.String title,
                                                java.lang.String folderName)
Returns null if user leaves the file selection dialogue by the cancel button.


selectOutputFile

public static java.lang.String selectOutputFile(java.lang.String title,
                                                java.lang.String folderName,
                                                javax.swing.filechooser.FileFilter[] filters)
Returns null if user leaves the file selection dialogue by the cancel button.


selectOutputFile

public static java.lang.String selectOutputFile(java.lang.String title,
                                                java.lang.String folderName,
                                                javax.swing.filechooser.FileFilter[] filters,
                                                java.lang.String initialFileName)
Returns null if user leaves the file selection dialogue by the cancel button.


getCurrentFilter

public static javax.swing.filechooser.FileFilter getCurrentFilter()