Search code examples
javatomcatmkdir

Java's mkdir failure


I am trying to create a directory by java's mkdir method.

The problem that it fails and I think because of access restriction. Tomcat is running under tomcat7 user, the folder's owner is tomcat7 user too. Every subfolder has the same owner. But still this method fails (the path is valid).

Does anybody familiar with such problem? Thank you


Solution

  • public class TestClass6 {
            public static void main(String[] args)
        {
            String path = "c:/folder1/folder2";    // path of the folder you want to create
            File folder=new File(path);
            boolean exist=folder.exists();
            if(!exist){
                folder.mkdirs();
            }else{
                System.out.println("folder already exist");
            }
        }
    }