FTP Progress Bar

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top