-4

I have to create an exe file using java GUI in eclipse. In this tool I have a jButton and a jTextField. In the jTextField I will give the source path where new/updated file is there. I want that when I click the jbutton the files in the path should fetched for further processing. Please help me in doing this.

  • 2
    Possible duplicate of https://stackoverflow.com/questions/1844688/how-to-read-all-files-in-a-folder-from-java – Wamadahama Jun 05 '18 at 14:55
  • Have you read the [Stack Overflow tour](https://stackoverflow.com/tour)? You need to pay attention to the section "Get answers to practical, detailed questions". You need to show the code of what you have accomplished so far, and then only ask a **single** question about a **single** issue that keeps you from moving forward. Stack Overflow does not exist to get people to write your code for you. – Martin Bramwell Jun 05 '18 at 15:05

1 Answers1

2

Add an event listener to the JButton

showDialogButton.addActionListener(new ActionListener() {
  public void action(ActionEvent e)
  {
     ProcessFile(textField.getText());
  }

});

You process file function could look something like this

void ProcessFile(string fileName) {

    File folder = new File(fileName);
    File[] listOfFiles = folder.listFiles();

    for (File file : listOfFiles) {
      if (file.isFile()) {
          System.out.println(file.getName());
      }
    }
}

Please provide some examples of what you have tried before posting.

Wamadahama
  • 1,489
  • 13
  • 19