I m trying to upload multiple files in swings applications.I have declared an array to hold the values of selected files but when i click on upload button only 1 file is getting uploaded. How can i upload all selected files into database?
The code to Open and Upload File is ....
public void openFile()
{
JFileChooser jfc = new JFileChooser();
jfc.setMultiSelectionEnabled(true);// added line
int result = jfc.showOpenDialog(this);
if(result == JFileChooser.CANCEL_OPTION) return;
try {
ArrayList<String> FileData = new ArrayList<String>();
File[] file = jfc.getSelectedFiles();
String s=""; int c=0;
for(int i=0;i<file.length;i++) //added
{
jep.setText(file[i].toString()); // added
}
return FileData;
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage(),
"File error",JOptionPane.ERROR_MESSAGE);
}
}