如何将两个以上的文件夹附加到 user.home java

How to append more than two folders to user.home java

伙计们!我正在尝试将文件夹附加到 user.home 属性。它工作得很好,而我只使用了一个额外的文件夹。但是,当我尝试添加另外两个内容时(看起来像 user.home+folder1+folder2+folder3),它显示了 --- java.lang.IllegalArgumentException: 文件夹参数必须是一个有效的文件夹--- .我虽然有一些限制,但无法找出位置。

    String fullRoute = null;
    File homeDir = new File("MLog");
    if (!SiteCo.getEditor().getText().isEmpty() &&         
    !InciDate.getEditor().getText().isEmpty()) {
            homeDir.mkdirs();

      fullRoute = System.getProperty("user.home") + File.separator + 
     //SaveVarTo.getLastVisitedDirectory() +
                    SaveVarTo.AddPath(SiteCo.getValue().toString()) + 
     File.separator + SaveVarTo.AddPath(InciDate.getValue().toString());
        }
        else {homeDir.mkdirs();
    //   File.separator+homeDir.toString() - without it         
    fullRoute = 
    System.getProperty("user.home")+File.separator+homeDir.toString();}
                System.out.println(fullRoute);

            fileChooser.setInitialDirectory(new File(fullRoute));
        fileChooser.getExtensionFilters().addAll(
                new FileChooser.ExtensionFilter("XML Files", "*.xml"));


//sample of method
public class Variables{
public String AddPath(String name) {

        if (!name.isEmpty()) {
            //File nou = new File(getLastVisitedDirectory() +"\" + name);

            File nou = new File(name);
            if (!nou.exists()) {
                nou.mkdirs();

            } else {
                System.out.println("Folder already exists");
            }


        }
        else{name = null;}
        return name;
    }}
 String fullRoute = null;
    File homeDir = new File(System.getProperty("user.home"));

    if (SiteCo.getValue() !=null && InciDate.getValue() !=null) {

        System.out.println(SaveVarTo.getMainFolder());
        fullRoute = homeDir + File.separator + SaveVarTo.getMainFolder() +
                File.separator + SiteCo.getValue().toString() + 
    File.separator + InciDate.getValue().toString();

    } else {
        fullRoute = homeDir.toString();
    }

    System.out.println(fullRoute);
    File fhd = new File(fullRoute);
    if (!fhd.exists())
        fhd.mkdirs();
    fileChooser.setInitialDirectory(fhd);
    fileChooser.getExtensionFilters().addAll(
            new FileChooser.ExtensionFilter("XML Files", "*.xml"));