当前位置:网站首页>FTP cannot create multi-level directories [circular creation problem]
FTP cannot create multi-level directories [circular creation problem]
2022-07-21 20:16:00 【Rainbow sea.】
About report export ftp File server , At first, the file upload path is stored in a string , And then use ftp.makedir(path), Later, I found that I can't use its own method to create multi-level directories . Then check the Internet , According to the blogs of the big guys, we get the applicable multi-level directory creation method . Here you can record .
/**
* ftp Create directory ——ftpClient Only level by level creation is supported
*
* @param ftp
* @param path
* @return
* @throws IOException
*/
boolean makeDir(FTPClient ftp, String path) throws IOException {
// Division
String[] paths = path.split("/");
// Create success id
boolean isMakeSucess = false;
// Traverse each level of path
for (String str : paths) {
// Toggle directory , Determine whether the subdirectory exists according to whether the switch is successful
boolean changeSuccess = ftp.changeWorkingDirectory(str);
// Create and switch if the path of this level does not exist
if (!changeSuccess) {
isMakeSucess = ftp.makeDirectory(str);
ftp.changeWorkingDirectory(str);
}
}
return isMakeSucess;
}
边栏推荐
- 微信公眾號開發接入,利用微信公眾平臺申請測試號進行本地開發
- Linux系统Redis安装
- JFrame需要调整大小才可以显示控件 在JPanel中setBounds()方法不起作用
- 对项目优化之一:redis缓存数据库的安装与项目中使用,加强项目读取操作
- Starfish OS: create a new paradigm of the meta universe with reality as the link
- 数据库宿舍管理系统
- CentOS 8中Docker安装MySQL8
- Nacos注册中心集群数据一致性问题
- MySQL之DML(数据操纵语言)
- MySQL UPDATE statement or delete statement where condition will lock the table if there is no index
猜你喜欢
Introduction, installation and basic use of MYCAT
JSON tool class
NIO三大核心详解
Nacos-配置中心原理解析
Solutions: connections could not be acquired from the underlying database!
以独占的方式锁定此配置文件失败。另一个正在运行的VMware进程可能正在使用配置文件。
PyTorch基础模块和实践
Gradually understand the deep belief network
数据类型Map判空 、空字符串、空key值等各种判断方法,全网最详细
解决Oracle数据库查询单表排序顺序错误问题之一
随机推荐
MySQL UPDATE statement or delete statement where condition will lock the table if there is no index
Data type map, empty string, empty key value and other judgment methods are the most detailed in the whole network
Original code, inverse code, complement and logical operation "and or not"
Json工具 将对象转换为json格式字符串
Paper reading (61):multi instance attention network for few shot learning
Address Book Implementation
NIO三大核心详解
PyTorch的模型定义
14. Can you tell the difference between process and thread
Character function and memory function
Judge whether there are duplicate values in the "string []" array, and use the HashSet feature to check
Automatic packet capturing tool web scraper
Wechat official account development access, using wechat public platform to apply for test number for local development
IDEA2020打开Run Dashboard
Forms form validation
Starfish OS: create a new paradigm of the meta universe with reality as the link
LeetCode 76. Minimum covering substring sliding window method
Database design introduction to database system (Fifth Edition)
869. Trial division for divisor
Notes on the method of construction - Chapter 6 agile process