• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating directory using mkdirs()

 
prachi jahagirdar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to create directory using mkdirs command. I am working on Linux.

<code>
File fTest = new File("/software/test/1");
System.out.println(fTest.mkdirs());
</code>

It always returns false
I tried creating directory from the prompt.... It gets created, but don't know whats the problem with above code.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the I/O and Streams forum..
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that you are logged in as a user and when you manually create the directory, you do it in your home directory. Your code, however, is attempting to create the directory off the root directory, which a mere user cannot do. Replace the file constructor with this line:

and see if that does what you want it to.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!