Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a folder w/ Java

 
Bill White
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bill White
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
     
    Bill White
    Ranch Hand
    Posts: 82
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The file already existed. Problem fixed thanks
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic