重複の可能性:
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、デスクトップなどのルートまたはホームディレクトリコンポーネントを切り取りたい