public static File fileName() throws CancelException, IOException {
        JFileChooser fd = new JFileChooser(".");
        FileFilter filter = new FileNameExtensionFilter(
                "Text file (*.txt)", "txt");
        fd.addChoosableFileFilter(filter);
        int returnVal = fd.showOpenDialog(null);
        if(returnVal == JFileChooser.APPROVE_OPTION) {
            return fd.getSelectedFile();
        }
        else if (returnVal == JFileChooser.CANCEL_OPTION)
            throw new CancelException();
        else {
            System.out.print("Error opening file!");
            throw new IOException();
        }
    }