Java Utililty Methods JFileChooser

List of utility methods to do JFileChooser

Description

The list of methods to do JFileChooser are organized into topic(s).

Method

voidsetSelectedFile(JFileChooser chooser, File file)
Set starting dir and file for a chooser.
if (file.isDirectory())
    chooser.setCurrentDirectory(file);
else
    chooser.setSelectedFile(file);
JFileChooserSHOW_JFILECHOOSER(String title, String approvetext, int fileselectionmode, boolean multiselection)
SHOJFILECHOOSER
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle(title);
chooser.setApproveButtonText(approvetext);
chooser.setFileSelectionMode(fileselectionmode);
chooser.setMultiSelectionEnabled(multiselection);
return chooser;
intshowFileChooserLoop(Component parentComponent, JFileChooser chooser)
show File Chooser Loop
for (;;) {
    int option = chooser.showOpenDialog(parentComponent);
    if (option != JFileChooser.APPROVE_OPTION) {
        return JOptionPane.CANCEL_OPTION;
    File file = chooser.getSelectedFile();
    if (file.exists()) {
        int op2 = showReplaceExistingFileConfirmDialog(parentComponent, file);
...
voidwrite(File file, String text)
write
write(file.toPath(), text);
voidwriteOnFile(String row)
write On File
writeOnFile(getFileFromChooser().getAbsolutePath(), row);
voidwriteStringToFile(String output)
write String To File
final JFileChooser fc = new JFileChooser();
int returnVal = fc.showSaveDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
    try {
        BufferedWriter bwriter = new BufferedWriter(new FileWriter(fc.getSelectedFile()));
        bwriter.write(output, 0, output.length());
        bwriter.close();
    } catch (IOException e) {
...