SAE21_2022/FileImport.java

20 lines
595 B
Java
Raw Normal View History

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();
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;
}
}