if (!ftpFile.getName().equals(".")
&& (!ftpFile.getName().equals(".."))) {
removeDirectory(path + "/" + name, true);
}
} else if (ftpFile.isFile()) {
log.info("* [sF]Delete file [" + path + "/" + name + "]");
deleteFile(path + "/" + name);
} else if (ftpFile.isSymbolicLink()) {
} else if (ftpFile.isUnknown()) {
}
}
return ftpClient.removeDirectory(path);
}
/**
* 查看目录是否存在
* @param path
* @return
* @throws IOException
*/
public boolean isDirectoryExists(String path) throws IOException {
boolean flag = false;
FTPFile[] ftpFileArr = ftpClient.listFiles(path);
for (FTPFile ftpFile : ftpFileArr) {
if (ftpFile.isDirectory()
&& ftpFile.getName().equalsIgnoreCase(path)) {
flag = true;
break;
}
}
return flag;
}
/**
* 得到某个目录下的文件名列表
* @param path
* @return
* @throws IOException
*/
public List
// listFiles return contains directory and file, it's FTPFile instance
// listNames() contains directory, so using following to filer
// directory.
// String[] fileNameArr = ftpClient.listNames(path);
FTPFile[] ftpFiles = ftpClient.listFiles(path);
List
if (ftpFiles == null || ftpFiles.length == 0) {
return retList;
}
for (FTPFile ftpFile : ftpFiles) {
if (ftpFile.isFile()) {
retList.add(ftpFile.getName());
}
}
return retList;
}
public boolean deleteFile(String pathName) throws IOException {
return ftpClient.deleteFile(pathName);
}
/**
* 上传文件到FTP服务器,支持断点续传
* @param local 本地文件名称,绝对路径
* @param remote 远程文件路径,按照Linux上的路径指定方式,支持多级目录嵌套,支持递归创建不存在的目录结构
* @return 上传结果
* @throws IOException
*/
public UploadStatus upload(String local, String remote) throws IOException {