如果是servlet,则mkdirs()始终返回false ..并且无法创建目录

时间:2018-07-19 12:32:58

标签: java jsp servlets

public class CreateDirectoryExample {

  public static void createF(){
    File file = new File("C:\\Directory1");
    if (!file.exists()) {
        if (file.mkdir()) {
            System.out.println("Directory is created!");
        } else {
            System.out.println("Failed to create directory!");
        }
    }

    File files = new File("C:\\Directory2\\Sub2\\Sub-Sub2");
    if (!files.exists()) {
        if (files.mkdirs()) {
            System.out.println("Multiple directories are created!");
        } else {
            System.out.println("Failed to create multiple directories!");
        }
    }

  }

}

此代码作为简单的Java类工作。但是当它通过servlet / jsp调用时并没有唤醒...

0 个答案:

没有答案