SAE21_2022/FileImport.java
2023-04-28 19:17:35 +02:00

30 lines
808 B
Java

import javax.swing.*;
import java.io.File;
public class FileImport {
private String ce_chemin;
public FileImport(){
this.ce_chemin = "";
}
public String Parcours(){
JFileChooser fileChooser = new JFileChooser();
try {
int option = fileChooser.showOpenDialog(null);
if (option == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
this.ce_chemin = selectedFile.getAbsolutePath();
} else {
System.out.println("Aucun fichier sélectionné");
}
} catch (Exception e) {
System.out.println("Voici l'eereur rencontrée: " + e.getMessage());
this.ce_chemin = "";
}
return this.ce_chemin;
}
}