//获取桌面地址 FileSystemView fsv = FileSystemView.getFileSystemView(); File com=fsv.getHomeDirectory(); System.out.println(com.getPath()); String path="ftp://10.1.48.35/KM_14_36/2020-12-29/KM_20_13978.dwg"; String substr=path.substring(0,path.lastIndexOf("/")); //获取文件名 System.out.println(path.substring(path.lastIndexOf("/")+1)); System.out.println(substr); 获取第一个符号的位置 int index=path.indexOf("/"); //获取第三个符号的位置 int index1=path.indexOf("/",index+2); 取出第二个位置以后的内容 System.out.println(path.substring(index1));
12-08
1089
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)