my dog learned polymorphism*
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 Murach's Java Servlets and JSP this week in the Servlets 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I/O Question.
 
Similar Threads
IO doubt?
K&B 5 Chapter 6 Question 12
I/O K&B Question
file renameTo() method
A doubt about renaming a file