S
stinehelferw
Using net commons.
Created a GUI FTP program similar to WS_FTP.
All working well, but interested in adding progress bar.
Looking at using a second thread to monitor the progress and report back to
main.
Here's the portion of program using ftp.retreivefile and FileOutputStream.
leftButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e16) {
// Retreive file(s) from remote system
// Find name of selected file for download in JLIST
String filename = remotefileList.getSelectedValue().toString();
String[] splitArray = null;
splitArray = filename.split(" ");
int i;
File destination = currentDir;
try {
messageTextArea.append("\n" + "Retreive File:" +
splitArray[0].toString().trim());
filename = splitArray[0].toString().trim();
File path = new File( destination + File.separator + filename);
FileOutputStream fos = new FileOutputStream( path );
ftp.retrieveFile( filename, fos );
messageTextArea.append("\n" + ftp.getReplyString()+ "\n");
fos.close();
filenameArray = currentDir.list();
locallistModel.clear();
locallistModel.addElement("[..]");
for(i=0;i<filenameArray.length;i++)
{
locallistModel.addElement(filenameArray);
}
}
catch(FileNotFoundException e) { }
catch(IOException e) { }
}});
Created a GUI FTP program similar to WS_FTP.
All working well, but interested in adding progress bar.
Looking at using a second thread to monitor the progress and report back to
main.
Here's the portion of program using ftp.retreivefile and FileOutputStream.
leftButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e16) {
// Retreive file(s) from remote system
// Find name of selected file for download in JLIST
String filename = remotefileList.getSelectedValue().toString();
String[] splitArray = null;
splitArray = filename.split(" ");
int i;
File destination = currentDir;
try {
messageTextArea.append("\n" + "Retreive File:" +
splitArray[0].toString().trim());
filename = splitArray[0].toString().trim();
File path = new File( destination + File.separator + filename);
FileOutputStream fos = new FileOutputStream( path );
ftp.retrieveFile( filename, fos );
messageTextArea.append("\n" + ftp.getReplyString()+ "\n");
fos.close();
filenameArray = currentDir.list();
locallistModel.clear();
locallistModel.addElement("[..]");
for(i=0;i<filenameArray.length;i++)
{
locallistModel.addElement(filenameArray);
}
}
catch(FileNotFoundException e) { }
catch(IOException e) { }
}});