aspose file tools*
The moose likes Java in General and the fly likes Creating a folder w/ Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Creating a folder w/ Java" Watch "Creating a folder w/ Java" New topic
Author

Creating a folder w/ Java

Bill White
Ranch Hand

Joined: Oct 27, 2002
Posts: 82
I can create files all day long... But I can't see how to create a folder...
Anyone have any ideas about how to do this?
Thank You.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
A folder (directory) is just a file that is dedicated to tracking other files. All that folder stuff is just illusion.
Look at the mkdir() method of File.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Bill White
Ranch Hand

Joined: Oct 27, 2002
Posts: 82
A folder (directory) is just a file that is dedicated to tracking other files. All that folder stuff is just illusion.
Correct

Look at the mkdir() method of File.
I did, kept returning false.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Oh. I really hate these File methods that just return false with no explanation. Let's see - things to check:
  • Does a directory or file with that name already exist?
  • Do you have write access in the parent directory you're trying to make a new directory in?
  • Do the parent directories for the new directory already exist? If not, try mkdirs() rather than mkdir().
  • Are you sure you know where the new directory would be created? Try file.getAbsolutePath() to see exactly where the system is trying to create the dir; it may not be where you think.

  • Good luck. If you find it's something else not on this list, please let us know for future reference.


    "I'm not back." - Bill Harding, Twister
    Bill White
    Ranch Hand

    Joined: Oct 27, 2002
    Posts: 82
    The file already existed. Problem fixed thanks
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Creating a folder w/ Java