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.... :(