SAE21_2022/FileImport.java

30 lines
808 B
Java
Raw Normal View History

import javax.swing.*;
import java.io.File;
public class FileImport {
private String ce_chemin;
2023-04-28 19:17:35 +02:00
public FileImport(){
this.ce_chemin = "";
2023-04-28 19:17:35 +02:00
}
public String Parcours(){
JFileChooser fileChooser = new JFileChooser();
2023-04-28 19:17:35 +02:00
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 = "";
}
2023-04-28 19:17:35 +02:00
return this.ce_chemin;
}
2023-04-28 19:17:35 +02:00
}