| Author |
I/O - creating a directory vs. not creating a dir
|
Derek Harper
Greenhorn
Joined: Aug 02, 2006
Posts: 25
|
|
Hi guys, I'm currently experimenting with creating files and directories. I've learned that it's good practice to "play" with code in order to gain a better understanding of how something works or doesn't work. Take a look at the following code: Now when i compile the program, i expect an exception to occur because the call to "mkdir' has been purposely omitted. However, the code compiles fine. However, when i look in the 'bin' directory, the "dexDir" is not there. My question is why didn't the program throw an exception? Is there something i did wrong or omitted from the code? Thanks in advance..... [ September 17, 2008: Message edited by: Derek Harper ]
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
It does throw an exception, but your ignoring that: If you put a "e.printStackTrace()" in there you'll see the error appearing.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Derek Harper
Greenhorn
Joined: Aug 02, 2006
Posts: 25
|
|
Ahhh, so that's what i forgot to do. You're exactly right because once i added the e.printStackTrace() to the code, i got the following: java.io.IOException: The system cannot find the path specified at java.io.WinNTFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(File.java:883) at NoFileDirDemo.main(NoFileDirDemo.java:11) Thanks Rob!
|
 |
 |
|
|
subject: I/O - creating a directory vs. not creating a dir
|
|
|