com.holub.io
Class Files

java.lang.Object
  extended by com.holub.io.Files

public class Files
extends Object

A utility that handles various File-related operations.


Constructor Summary
Files()
           
 
Method Summary
static File userSelected(String startHere, String extension, String description, String selectButtonText)
          Throw up a file choser and return the file that the user selects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Files

public Files()
Method Detail

userSelected

public static File userSelected(String startHere,
                                String extension,
                                String description,
                                String selectButtonText)
                         throws FileNotFoundException
Throw up a file choser and return the file that the user selects.

Parameters:
extension - File extension (text following the rightmost dot in the name) that you're looking for. Use null if any will do.
description - the description of what the extension means. Not used if "extension" is null.
selectButtonText - Replaces the "Open" on the chooser button.
startHere - Name of initial directory in which to look.
Returns:
a File representing the selected file.
Throws:
FileNotFoundException - if the user didn't select a file. An exception toss (as compared to a null return value) makes it easy to do the following:
  FileInputStream in =
        new FileInputStream(
                                         Files.userSelected(".",".txt","Text File","Open"));