• Post Reply Bookmark Topic Watch Topic
  • New Topic

File.mkdir() broken ?  RSS feed

 
Edward Kenworthy
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to create a directory using File.mkdir() (and File.mkdirs()) but neither works! I don't get an exception, and mkdir returns true but when I check the file system no directory has been created and this is driving me up the wall!

I'm using the latest 1.4 JDK on OSX.

HELP!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Often files may not be located where you think they are - especially if the path is relative. Do you know for sure what the current working directory is when the code is executing? That's what your Java uses as the base, when evaluating relative paths. I suggest

to make sure you know what path the File is referring to. I suspect you'll find that the directory is getting created, but not where you expect.
 
Edward Kenworthy
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Yingst:
Often files may not be located where you think they are - especially if the path is relative.


Hi, yes good idea but I'd already thought of that one: firstly I use absolute paths to create and also log the paths being used to create the dirs and to make extra sure I simplified the path to /trash (so it should have created /trash/backup) but still no joy.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder if this is a Mac-specific issue. Would you like me to move this thread to our Java-on-Mac forum?
 
Edward Kenworthy
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
I wonder if this is a Mac-specific issue. Would you like me to move this thread to our Java-on-Mac forum?


I was wondering the same thing and then I thought "hmm I've wrapped my mkdirs in asserts()" and yes lo and behold the reason why the dirs weren't being called is because mkdir was never called.
[ October 02, 2004: Message edited by: Edward Kenworthy ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doh! Well, glad you solved it.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!