This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I/O Question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "I/O Question." Watch "I/O Question." New topic
Author

I/O Question.

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Hi.
This is a simple program, though it looks long.
All i have done is created 2 Directories.
In the Directory1, I have created 3 files, and deleted the second directory.
I have then renamed the Directory1 and tried to Delete it after Deleting the files( as directories won't be deleted unless they are empty.
How ever, for some reason my files arent gettting deleted due to which the directory is not getting Deleted.
I am not sure where the problem.
Could it be because when I have created a file , i have created it in the Directory1 folder and not the renamed Directory.
That was just a guess.

Here is the code.
Hope some one can help me out.
Thanks.



The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Irina Goble
Ranch Hand

Joined: May 09, 2004
Posts: 91
Originally posted by Nabila Mohammad:
Could it be because when I have created a file , i have created it in the Directory1 folder and not the renamed Directory.
That was just a guess.


That is correct. To see what happens, use a print statement:

It will print the file name and the result of the delete() call. To remove files from the renamed directory, use the list() or listFiles() methods of the File class.

PS. File names can be case-sensitive.
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Thanks Alot.
 
 
subject: I/O Question.