SAE21_2022/FileImport.java

23 lines
601 B
Java

import javax.swing.*;
import java.io.File;
public class FileImport {
String ce_chemin;
public FileImport(){
this.ce_chemin = "";
};
protected String Parcours(){
JFileChooser fileChooser = new JFileChooser();
int option = fileChooser.showOpenDialog(null);
if (option == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
this.ce_chemin = selectedFile.getAbsolutePath();
} else {
System.out.println("No file selected");
}
return this.ce_chemin;
}
}