public static void main(String args[]) {
try {
FtpClient ftp = new FtpClient("XXX.XXX.XXX.XXX",21);
ftp.login("down","down");
ftp.binary();
ftp.cd(GlobalConstant.FTP_URL);
try{
ftp.cd("/upload/20120708");
ftp.cd("/");
}catch(Exception e){
ftp.sendServer("XMKD /upload/20120708\r\n");
}
try{
ftp.cd("/upload/20120708/20120709");
ftp.cd("/");
}catch(Exception e){
ftp.sendServer("XMKD /upload/20120708/20120709\r\n");
}
ftp.cd("/upload/20120708/20120709");
ftp.cd(GlobalConstant.FTP_URL+"upload");
} catch (Exception e) {
e.printStackTrace();
}
}
新建文件夹,文件夹存在时,应该异常,但是我在使用时,总是执行到下一条命令才会抛出上条命令的异常,而java虚拟机会认为是当前命令的异常,所以try{}catch(){}的时候我选择了两条命令写在一起。