Java-无法创建文件夹

时间:2018-10-17 23:00:20

标签: file directory

我有一个使用Spring 2.0实现commandLineRunner的spring boot应用程序。我已经在src目录中创建了一个文件夹,并尝试使用我的Java代码访问该文件夹,然后使用以下代码在其中创建子目录。

enter image description here

@Override
public void run(String... strings) throws Exception {
    Path mediaPath = Paths.get("TEST_FOLDER");
    System.out.println("folder name is : " + mediaPath.toString());
    File testFile = new File(mediaPath.toString());
    if(testFile.exists()){
        System.out.println("file exists " );
        File newFolder = new File(mediaPath.toString()+"Sub_test");
        boolean created = newFolder.mkdir();
    }
}

我在控制台中看不到消息“文件存在”。 请帮助

0 个答案:

没有答案
相关问题