I want to upload a file into a local folder (on my PC). The user should select a file. Than this file should be loaded into a folder (this folder is hard coded in my Java class). Unfortunately I didn't find a good solution for this.
I just found something about a JFileChooser
which is nice to open a file, but not to load one.
public static void main(String[] args){
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"JPG & GIF Images", "jpg", "gif");
chooser.setFileFilter(filter);
int returnVal = chooser.showOpenDialog(null);
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose to open this file: " +
chooser.getSelectedFile().getName());
}
}
Is it possible to just give the file chooser access to a specific folder? the folder is hard coded like this:
public static String uploadPath = System.getProperty("user.dir") + "/uploads Modul1";