可能重复:
如何在java中拆分字符串
FileSystemView fsv = FileSystemView.getFileSystemView();
File[] roots = fsv.getRoots();
for (int i = 0; i < roots.length; i++)
{
System.out.println("Root: " + roots[i]);
}
System.out.println("Home directory: " + fsv.getHomeDirectory());
根目录:C:\Users\RS\Desktop 主目录:C:\Users\RS\Desktop
我想剪切根目录或主目录组件,如字符串 C、用户、RS、桌面