mkdir() is not creating the new directory

后端 未结 7 2159
庸人自扰
庸人自扰 2020-12-18 20:59

I am using Eclipse and jdk1.7. I am making a basic program using file handling, in which an output directory inside the directory is to be made. But when I run the program,

相关标签:
7条回答
  • 2020-12-18 21:40

    Create directory example

    it looks like you'll need to work on your path a bit as it doesn't look like File will infer "abc."

    Also, make sure you have permissions on the path you're attempting to create the directory. If you don't, it will fail. It has been a while since I've played with Java, so not sure if you'd need to do mkdir calls the entire way down the path (ie /here/, /here/now-here/, /here/now-here/final) or not. Think it may be recursive but that'd be worth verifying.

    Actually, from looking at the other answers looks like mkdirs would be recursive, mkdir is not. I'd go with mkdirs especially if the input isn't going to be known from the onset otherwise you'll end up writing a function with mkdir that does the exact same thing.

    0 讨论(0)
提交回复
热议问题