Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.7k views
in Java FTP by
When i download a file in the FTP which is 3MB in size the gui and program hangs but the console window is displaying the downloaded byte size. I want the download byte status to be shown in the GUI. Here's my code:

try{


int a=0;

a = JOptionPane.showConfirmDialog(menugui, "Do you want to download updates?");

if(a == 0)//IF YESS
{
menugui.getLblMessages().setText("Loading Database... Please wait....");

ftp=new FTPClient();
ftp.setRemoteHost("my ftp");
FTPMessageCollector listener = new FTPMessageCollector();
ftp.setMessageListener(listener);

ftp.connect();
ftp.login("username", "password");
ftp.chdir("BJT");

FTPProgressMonitor h = new TestProgressMonitor();

ftp.setProgressMonitor(h, 2048);
ftp.setType(FTPTransferType.BINARY);

ftp.get("file.file","file.file");


ftp.quit();
menugui.getLblMessages().setText("Database Download Complete.");

JOptionPane.showMessageDialog(menugui, "Downloaded Complete!");
}
else
{
//IF NO
}

}
catch(Exception ex)
{
System.out.println(ex);
}


The file is downloaded and it shows the dowload status in the console window as string but the program hangs while the file is being downloaded....

Please help.... :(

6 Answers

0 votes
by (162k points)
You'll need to download in a separate thread.
0 votes
by
I'm sorry but I'm really a begginer about this, but what do you mean about download in a seperate thread? You mean I'll create another GUI to download?

Please explain in the most basic term :wink:

Thanks!
0 votes
by
Ok, I created another GUI and it still does the same... I created anothe java class and still the program hangs... what will I do..

please somebody help and explain it to me... :(
0 votes
by
Hehhe... ok i know now...

Multi-threading eh... ^_^
0 votes
by (162k points)
FYI we will soon be releasing edtFTPnet Express, which supports asynchronous downloads.

Hehhe... ok i know now...

Multi-threading eh... ^_^
0 votes
by
Really? I don't knwo what it will do but if it will solve download problems then its very good!

I do have lots of problems and unknown exceptions recently in uploads and downloads... but its ok now. THanks! ^_^

Categories

...