使用java 实现递增截取目录,目录路径为:/nas/ytdata/TM03/rawLog/2023/04/02/
时间: 2023-08-26 14:06:58 浏览: 137
dafangkuai.rar_FlashMX/Flex源码_FlashMX_
以下是Java代码实现:
```
String path = "/nas/ytdata/TM03/rawLog/2023/04/02/";
String[] dirs = path.split("/");
for(int i=0; i<dirs.length; i++){
String subPath = "";
for(int j=0; j<=i; j++){
subPath += dirs[j] + "/";
}
System.out.println(subPath);
}
```
输出结果:
```
/
/nas/
/nas/ytdata/
/nas/ytdata/TM03/
/nas/ytdata/TM03/rawLog/
/nas/ytdata/TM03/rawLog/2023/
/nas/ytdata/TM03/rawLog/2023/04/
/nas/ytdata/TM03/rawLog/2023/04/02/
```
阅读全文