java - Change fileChooser to multiple-fileChooser and iterate through those files -


i've written code open , read individual files (of specific filetypes) need same, folder full of these files. i've found this question have no idea how change around need.

here's current code.

    jfilechooser infilename = new jfilechooser(new      file("c:\\documents , settings\\lucey01\\desktop\\projects\\c0048817\\koi\\c0048817_pcf_front"));            \\this default folder      filenameextensionfilter filter = new filenameextensionfilter("pcf & txt files", "pcf", "txt");     infilename.setfilefilter(filter);      component parent = null;      {       returnval1 = infilename.showopendialog(parent);       if (returnval1 == jfilechooser.cancel_option) {           returnval2 = joptionpane.showconfirmdialog(null, "select yes cancel. select no restart",           "are sure?", joptionpane.yes_no_option);           if (returnval2 == joptionpane.yes_option) {             system.exit(returnval2);             }else{              checksumgui.this.askdirectory();            }       }    } while (returnval1 == joptionpane.cancel_option);      cf.hexfinder(infilename,null,null,null); 

edit question is: there (small) thing can add/change code work on multiple files of specific types in folder?

any appreciated, thanks.

ok, here's sscce. of code found here, useful. code compile , there seems no trouble it. after little debugging still don't know why won't work

package robertskostalproject;  import java.awt.component; import java.io.file; import java.io.filenotfoundexception; import java.io.ioexception; import java.io.unsupportedencodingexception; import javax.swing.*; import javax.swing.filechooser.filenameextensionfilter;  public class checksumgui {   private checksumfinder cf = new checksumfinder();  private static int returnval1;  private static int returnval2;  public void askdirectory() throws filenotfoundexception, unsupportedencodingexception, ioexception {      jfilechooser infilename = new jfilechooser(new file("c:\\documents , settings\\lucey01\\desktop\\projects\\c0048817\\koi"));     infilename.setfileselectionmode(jfilechooser.directories_only);      component parent = null;      {       returnval1 = infilename.showopendialog(parent);      if (returnval1 == jfilechooser.cancel_option) {         returnval2 = joptionpane.showconfirmdialog(null, "select yes cancel. select no restart",         "are sure?", joptionpane.yes_no_option);           if (returnval2 == joptionpane.yes_option) {              system.exit(returnval2);           } else {             checksumgui.this.askdirectory();          }       }      } while (returnval1 == joptionpane.cancel_option);    file folder = infilename.getselectedfile();   file[] listoffiles = folder.listfiles();   (int = 0; < listoffiles.length; i++) {    file file = listoffiles[i];    if (file.isfile() && file.getname().endswith(".txt") || file.getname().endswith(".pcf")) {      cf.hexfinder(infilename, null, null, null);    }else {     system.out.println("file not of correct type");    }   }  } } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -