Is there a way to delete a directory with files in it?

I am working on a program right now, and i need to know if there is a way to delete a directory that has files in it?
or do i have to write another program that gets the list and deletes each file individually? if this is the solution, how do you do this?
Right now, i would prefer some of the logic and some "code snippets" but please do not write the entire code out for me.
thank you.
(snippets include how to poll, and how to call the polled item so i can delete it...)

Right now, i would prefer some of the logic andsome "code snippets" but
please do not write the entire code out for me.So I assume this is some sort of "homework" (maybe
self imposed).
You can't use File's delete() to delete a non empty
directory as I guess you
have discovered. So basically, yes, you have delete
each child file
separately and then delete the directory.
But it gets worse. The directory may itself contain
directories and these may
not be empty...
There's a fairly extensive snippet here:
http://www.exampledepot.com/egs/java.io/TraverseTree.h
tml which shows
how you can "visit" every file and folder inside a
given folder (children,
grandchildren etc) and "process" them. It may help -
but be warned there's
a nearby example which more or less solves your
problem.Um, did my post above get covered with lemon juice or otherwise become invisible?
Jakarta Commons IO FileUtils already does the job.

Similar Messages

  • Is there a way to delete all events with the same title (not added as reoccurring) without deleting one at a time?

    i currently have a calendar synced that has events scheduled in perpetuity, scheduled as individual events.  I would like to delete all events with the same title.  I do not want to delete the entire calendar nor do I want to go into every event and delete individually.  These were not scheduled by me so I do not know how they were added one by one and go on forever but they are NOT scheduled as reoccurring and thus must be modified individually.
    I can do a search and find all events, is there a way to just delete all events with the same title all at once?
    this is a Microsoft outlook synced calendar and I am seemingly unable to delete the events all at one time from Microsoft as well. 
    Please help!

    If you still have access to the Outlook calendar in Outlook, I would delete them from there. There are a number of ways to do that, but if you open the individual event in Outlook, does it show a repeating pattern? If not, then you may have to delete them individually, but that is not that difficult either. Go into the calendar and then change the view to a list view. From there you can sort the view according to subject. This should bring all of these same appointments together in the list and you can select the group in Outlook and delete them. Once you do that, you can change your view back and then sync the phone. That will remove the events from the phone.

  • Is there a way to delete more then 1 file at a time?

    I inserted a CD from a friend of mine, it was suppose to be my wedding photo's. It was not.....it downloaded automatically all the contents of the CD into my photo's and there was over a thousand images entered.
    I believe this is why my I Photo is not opening. I need to first delete these images, then i will run the test to see if it corrupted my I Photo.
    But doing this one at a time has become a lengthy process. I have tried highlighting them, but still it only allows to me move to trash one at a time.
    Thank you,
    Suzanne 

    If you are running Time Machine then the iPhoto library should be backed up - store instructions are near the end of this article - Mac Basics: Time Machine backs up your Mac - Apple Support
    If you do not have a backup then you have made a mess of things and with no backup you have no way to totally recover
    If you have no backup try to rebuild although it is not likely to work completely - maybe not at all - Back up your iPhoto library, Depress and hold the option (alt) and command keys and launch iPhoto - from the resulting first aid window repair permissions and if necessary rebuild your database
    LN

  • Ok Apple users...Is there a way to delete e-mails on my Mac and not have to delete the same e-mails on my iPhone, and iPad...and vise-versa. I have the Cloud, and thought that everything would sync all of the time. If you know of a setting I need to adjus

    Ok Apple users...Is there a way to delete e-mails on my Mac and not have to delete the same e-mails on my iPhone, and iPad...and vise-versa. I have the Cloud, and thought that everything would sync all of the time. If you know of a setting I need to adjust, please let me know.

    Are you referring to @mac.com, @me.com or @icloud.com emails? Or some other email providers emails?
    If the former, it should do that automatically. If the latter, no. iCloud does not (nor is it supposed to) sync non-Apple provided emails.

  • Is there a way to delete only cookies in safari 5.1?

    Is there a way to delete only cookies in safari 5.1?
    If you go to Preferences -> Privacy -> details, you can choose to remove "website data" but sometimes this includes the local cache and also local storage.
    Is there any way to delete JUST/SOLEY the cookies that the browser stores?

    Go to ~/Library/Cookies.
    Move the Cookies.plist to the Trash.
    ~ (Tilde) character represents the Home folder.
    For LIon:   To find the Home folder in OS X Lion, open the Finder, hold the Option key, and choose Go > Library

  • Is there a way to delete multiple pictures at the same time from the iphone4s?

    Is there a way to deleter multiple pictures at the same time, from my iphone4s? I know how to delete one at a time. Thanks

    Open your Photos App > Camera Roll > At the top right corner you will see a rectangle with a right arrow, select that. Now you can select as many photos as you want and you can hit the red Delete button on the bottom right.

  • After I watch a podcast I delete it. When I go back in the next day it shows 500-600 episodes I have to delete manually. So 2 questions....  Is there a way to stop this from happening and is there a way to delete all. This is getting frustrating.

    After I watch a podcast I delete it. When I go back in there are 500-600 episodes and I have to delete each one manually. Is there a way to stop this from happening or is there a way to delete all at once. It's getting very frustrating.

    Had all these issues.  Bit the bullet and downloaded the Downcast App ($1.99).  Much better expereince and a lot more features.  Sad.

  • Is there a way to delete photos from Photo Stream on my macbook pro? (Not from my folders,etc.) I need to empty the photo stream. Something in my photo stream has corrupted my phone and my apple specialist suggested I do this.

    Is there a way to delete the photos in Photo Stream on my mackbook pro notebook?
    My phone became corrupted today and, after continuing to have problems with 2 new phones, the apple specialists determined that the only possible explanation was the presence of a corrupted photo or video in photo stream; and that the only way to use my phone without it shutting down was to deactivate the photo stream on it.  It worked, but I would like to be able to have the option of using photostream again. The apple folks suggested that I delete all photos from photo stream on my computer; and then, when it is "empty", reactivate it on my phone? Is anyone familiar with this problem?

    If it says Not Enough Storage Space on iCloud then you can get more Storage space for iCloud if you want to backup more Data on iCloud Storage. You will find the Pricing for Additional Storage Space and how to Buy Storage Space for iCloud from your Device in the Link below.
    http://support.apple.com/kb/ht4874
    http://support.apple.com/kb/HT5879

  • I have deleted a contact on my phone, and they are no longer in my contacts list however when I go to text there name still appears as (other) is there a way of deleting them completely of my phone? - I have tried everything!!

    I have deleted a contact on my phone, and they are no longer in my contacts list however when I go to text if i type in the letter there name begins with there name still appears as (other) is there a way of deleting them completely of my phone? - I have tried everything!!
    I have resorted my phone, used the spring clean app - none of these work, Have I saved this number somewhere else but I just can't get to it?

    You got the new iphone?????   I have same problem.  I transferred audiobooks to device to find no audiobooks on device (despite it being in iTunes as if it was).  Have you found a solution?????   I even tried to change import settings on format transfer but hasn't worked. 

  • Is there a way to delete more than one photo at a time in the Photo application?

    Is there a way to delete more than one photo at a time in the application Photos in the iPad? Thanks.

    The links below have instructions for deleting photos.
    iOS and iPod: Syncing photos using iTunes
    http://support.apple.com/kb/HT4236
    iPad Tip: How to Delete Photos from Your iPad in the Photos App
    http://ipadacademy.com/2011/08/ipad-tip-how-to-delete-photos-from-your-ipad-in-t he-photos-app
    Another Way to Quickly Delete Photos from Your iPad (Mac Only)
    http://ipadacademy.com/2011/09/another-way-to-quickly-delete-photos-from-your-ip ad-mac-only
    How to Delete Photos from iPad
    http://www.wondershare.com/apple-idevice/how-to-delete-photos-from-ipad.html
    How to: Batch Delete Photos on the iPad
    http://www.lifeisaprayer.com/blog/2010/how-batch-delete-photos-ipad
    (With iOS 5.1, use 2 fingers)
    How to Delete Photos from iCloud’s Photo Stream
    http://www.cultofmac.com/124235/how-to-delete-photos-from-iclouds-photo-stream/
     Cheers, Tom

  • Is there a way to delete the Apple ID on one device (IPhone 5) and replace the ID on that device with an existing ID used on three other devices?

    Is there a way to delete the Apple ID used on one device (IPhone5) and replace it with another ID that is being used on three other devices?

    If you have turned on Settings > iCloud > Find My you will have to start by turning that off - requires entering the Apple ID password.  Then remove the Apple ID from all places it is used, i.e., Messages, FaceTime, and so on.  Go to the App Store and then Sign Out.  Now you can enter the desired Apple ID and password in all of those places.

  • When I import photos taken from my Ipod Touch 4 to My Mac Desktop, I click delete photos on ipod, but they do not delete. Is the only way to delete them individually (I have 1,400 photos!) or is there a way to delete them all in one go?

    When I import photos taken from my Ipod Touch 4 to My Mac Desktop, I click delete photos on ipod, but they do not delete. Is the only way to delete them individually (I have 1,400 photos!) or is there a way to delete them all in one go?
    I realise you can you can delete them on your ipod slowly as you have to click on each one, and you can restore your ipod, but surely there is a way to get around this?
    Software: 4.3.2
    Build Version: 8H7
    Thanks If anyone can help me.

    Download/install an app is a know possible solution.
    3. Install another app from the App Store
    If all user-installed apps are not launching, it could be an Apple ID authorization issue. Download and install an app that isn't already installed on your device to reset this information.
    Note: If you have installed apps using multiple Apple ID accounts, you may need to perform this step for each account.
    Above from Apple's :
    iOS: Troubleshooting applications purchased from the App Store

  • Is there a way to delete more than one message at a time

    on my iPhone 6 I can hit the edit link in messages and easily and quickly delete lots of messages at a time.  on my iMac it seems you have to delete one message at a time, which takes a lot more time........isn't there a way to delete messages in bulk in Yosemite messages?

    Hi,
    A single Bubble is a single Message or iMessages depending on the account it is with.
    A single bubble can be highlighted then the Backspace/Delete key used.  (the greys in this pic hardly differ to tell though)
    A whole chat/Conversation (Apple calls iMessages connections "conversations" and other connection have always been "Chats" since iChat 1) can be deleted by mousing over the chat in the list and using the x icon that appears without having to bring that one to the "front" or top.
    7:43 pm      Wednesday; March 18, 2015
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Why is there no way to delete all emails from my iphone?

    Why is there no way to delete all emails from my iphone? IOS 7.1. Every other phone in the market allows you to 'select all' then delete.
    This trick of selecting one, then holding move, then unchecking (and subsequently moving all the emails to trash) doesn't work. I've read these suggestions and while it appears to work the emails just show up again once you leave and return to the inbox. Perhaps it worked on an older version of IOS.
    It blows my mind this is not a standard function. I get a few hundred emails at work every day, and most of the time I just want to delete all of them from the phone as I've read them already. Currently it seems i can only click edit and then have to check each email individually to be able to delete them at the same time; this is the definition of tedious. I would think there are millions of other iphone users who get their company email on their phones that must experience the same thing. It seems now i either spend 20 minutes a day deleting emails, or just let thousands of emails accumulate on the phone (taking up space and also making it hard to just review the most recent emails which is all I want to be able to do when checking email on my phone).
    I am hoping I am just missing some simple solution here that everyone else uses. Please help!!
    Mark

    Only Apple could answer as to why there is no "select all/"delete all" function in the iOS mail app. Users have been bemoaning this lack of functionality for years now. Like everyone else, you can submit feedback to. Apple here.
    Apple - iPhone - Feedback
    While I understand the whole idea of being able to use the phone on the run, if you have an IMAP email account, and if you have access to a computer at work during the day, use your "select all" function on the server and delete all of the unwanted email there and it will be removed from the phone as well.
    That doesn't solve the problem on the phone, but it gets rid of the email which is your ultimate goal anyway.

  • Is there a way to "delete all" iMessages in OSx instead of one at a time?

    Is there a way to "delete all" iMessages in OS 10 (Yosemite) instead of one at a time? Now the only way seems to select each one, wait for the little "X" to pop up, select that, hit return to confirm delete, then do it again, and again, and again...
    Mike

    Hi,
    You can highlight a chat by the list in the left of the main window and then use the File Menu > Delete conversation
    Using the x only dismisses the chat from view.
    Individual iMessages can be deleted one at a time by clicking on a Bubble but not the text (you will see bubble and text change in colour slightly) and then the Backspace key.
    It is not possible to Clear in any way all the chats/conversation in the left hand list.
    8:51 pm      Wednesday; April 22, 2015
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

Maybe you are looking for

  • Ipods fail to get recognized by itunes but appear in my computer - already tried different solutions

    Hello, i have iPod nano 6th generation 8GB and while it is recognized in My computer it isn't recognized in iTunes. When i plug the device on my mac it recognizes it and synces properly. When i first plugged my nano on my PC it said it can't be recog

  • FrameMaker 11 very slow to create PDF

    Hello All Using FrameMaker 11 (TCS4) on Windows Vista SP2 (32-bit), dual-core 2.8GHz, 4GB RAM. I have a book file with nine chapters, title, TOC and Index, adding up to about 550 pages when printed. It used to take about 10 minutes to create PDF usin

  • Very simple mp3 player

    What is an easy way to create a very simple flash mp3 player in DW CS3? I tried the DW mp3 plugin, but that caused confusion for visitors who did not know how or want to install a plugin. I googled "flash mp3 player" and there are many available, but

  • How to send an attachment with adobe form

    Hi in my application i have two process intiator and approval process both are adobe interactive forms,according to my scenarion i need to send an attachment(pdf or word document....)in intiatior to approval process,can pleasse tell me how to send th

  • Differeance between SAP BPC 5.1 and SAP BPC 7.0 NW  Version

    Dear experts, Please contribute your expertise and valuable answers to this question. what is the script language we need to use in SAP BPC 7.0 NW version? SQL or ABAP..? What are the new features and positions are added in SAP BPC 7.0 NW comparing t