java ftp上传过程中服务器断连后怎么重新连接

public boolean upload(File file,XML xml1) throws Exception{
try {
bstate=0;
while(ftp==null || bstate<2)
{
sleep(500);
bstate=connect(xml1);
if(ftp==null || bstate<2){
System.out.println("连接服务器失败,请检查服务器是否开启!");
}
}
if(file.isDirectory()){

ftp.makeDirectory(file.getName());

ftp.changeWorkingDirectory(file.getName());

String[] files = file.list();

for (int i = 0; i < files.length; i++) {

File file1 = new File(file.getPath()+"\"+files[i] );

if(file1.isDirectory()){

upload(file1,xml1);

ftp.changeToParentDirectory();

}else{

File file2 = new File(file.getPath()+"\"+files[i]);

FileInputStream input = new FileInputStream(file2);

ftp.storeFile(file2.getName(), input);

input.close();

}
}
}else{

File file2 = new File(file.getPath());

FileInputStream input = new FileInputStream(file2);

ftp.storeFile(file2.getName(), input);
bsc=true;
input.close();

}

        ftp.logout();
    } catch (Exception e) {
        e.printStackTrace();
    }finally {
        try {
            ftp.disconnect();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    } 
    return bsc;
} 


    程序执行到粗体字除,也就是上传过程中,服务器断开了要怎么设置隔几分钟重新连接一次

断开了进入你的catch了,你自己设置定时器到时候重新调用呗

可是他不会往下走了 ,写了catch他也不走