Recovering efficiently from an IOException.

Hi All,
I have a program that continuously "poles" various URLs and then establishes stream connections with those URLs. During the course of a program run any number of streams may be established. To date during program testing the program has successfully established approximately five hundred connections.
However inevitably this program comes to a "crashing" holt as a result of IOExceptions. Admittedly this program does not holt on the first occurence of an IOException. None the less IOExceptions causes this program to halt sooner or later.
I have come to the conclusion that IOExceptions occuring in my program are not always occuring when the stream connection is established. I am convinced that IOExceptions are sometimes occuring during stream communications. To this end I have tried to include a break statement in my streams code, however including the break statement has not helped. My code looks like this:
      inStream = xURL.openStream();
      outStream = new FileOutputStream(resourceFile);
      int in;
      byte[] buffer = new byte[1024];
      while((in = inStream.read(buffer)) != -1)
        outStream.write(buffer, 0, in);
          if(success_flag == false)
            break;
    }catch(MalformedURLException e){
      success_flag = false;
    }catch(FileNotFoundException e){
      success_flag = false;
    }catch(IOException e){
      success_flag = false;
  }The break statement included above is intended to break the code out of the while loop. Does the code work as I intend or is this simply causing the if statement to be exited rather than the while loop? Also
can somebody please suggest how to improve this code so that IOExceptions are not as big a problem as they are now. I cannot foresee a way to stop the exceptions from occuring however I need a very good way of recovering from them and continuing on with program operation.
Thanks for your assistance.
Regards
Davo

The break statement included above is intended to
break the code out of the while loop. Does the code
work as I intend or is this simply causing the if
statement to be exited rather than the while loop?A break statement exits the closest while, do, for and switch. So your if statement is fine.

Similar Messages

  • How do i repair or recover data from a corrupt USB external hard drive that does not show up on my Mac desktop or disk utility

    How do i repair or recover data from a corrupt USB external hard drive that does not show up on my Mac desktop or disk utility?
    Last night i was using my external hard drive, for some reason the folder just closed and i couldn't find it on my desktop.
    After googling solutions, i found it in the disk utilities, i clicked on the 'repair' button many times, but it said the 'error...' message.
    So i ejected it to try again, now when i connect the USB external hard drive it doesn't show up on my desktop or disk utilities.
    I really just want to either repair or recover the data on it because it literally has everything (documents, work files, photos etc) on it,
    I downloaded an application to recover my files but it needs the USB to at least show up.recognise it which mine doesn't.
    I know i should've backed it up on another USB, this definitely teaches me for next time to back up all my files.
    Are the files lost forever or can i recover them by going to a shop or using a software?

    Thank you for responding.
    This might sound stupid since i'm not really knowledgeable with Macs,
    but since all my files were moved from my mac computer to the external hard drive,
    is it possible to recover those files through my Mac - like recovering deleted files? 

  • HT1386 How can I recover music from an iPod to a new computer?

    I've lost all data from my computer and I want to recover music from my iPod. How can I do that?

    Recovering your iTunes library from your iPod or iOS device: Apple Support Communities

  • How do I recover photos from my AppleTV photo stream? when I reset my iPhone, I did not get all of my photos back. How do I get these photos off of my Apple TV?

    how do I recover photos from my AppleTV photo stream? when I reset my iPhone, I did not get all of my photos back. How do I get these photos off of my Apple TV?

    Hi MrRhea,
    Welcome to the Apple Support Communities!
    It sounds like you have photos in your Photo Stream that you would like to download. The photos are not actually stored on your Apple TV, it sounds like they are being displayed from your Photo Stream. Please read over the attached article for information on your Photo Stream and how to download these photos.
    My Photo Stream FAQ - Apple Support
    Because your Mac and PC have more storage than your iOS devices, you can choose to download all of your My Photo Stream photos automatically.
    In iPhoto or Aperture preferences on your Mac, select Photos (or Photo Stream) > My Photo Stream > Automatic Import. All of your photo stream photos will import into your Events, Projects, Photos, Faces, and Places folders in iPhoto or Aperture.
    On your PC with My Photo Stream on in the Control Panel, all of your photos will import intoC:\\Users\<user name>\Pictures\iCloud Photos\My Photo Stream
    Best regards,
    Joe

  • Recovering data from Time Capsule after conversion from Snow Leopard to Lion

    Had a problem with my iMac, which was running Snow Leopard O/S.  Data was backed up on Time Capsule using Time Machine, although recent back-ups had failed (but earlier back-ups had been OK).  Apple support determined that I needed to re-install the O/S and they walked me through it.  After blowing away all data (believing that once O/S reinstalled, could recover from Time Capsule), the reinstall failed.  Took to Apple store, where they installed Lion at my request.  Then tried to recover from Time Capsule, but couldn't do so.  Sparse file doesn't work (it shows 10GB, which is wrong as it had several hundred GB's before due to lots of photos).  Apple Support couldn't solve issue, believes it was corrupted with the last backup.  Ultimately recommended that I have professional data recovery service recover data from the iMac hard-drive (as opposed to Time Capsule).  Spoke to recovery service recommended by Apple, and it is very expensive (also, given the O/S reinstall, anything they recover will have new file names and no directory structure).  They also said getting data off the Time Capsule is even more difficult and expensive to recover.  I'm not a happy camper. 
    I would welcome any thoughts on what to do.  FWIW, I live in South Florida and there appear to be lots of data recovery companies locally, but Apple support had said that they have only a few authorized vendors that can do it without voiding warranty, so I'm reluctant to even call them.  Thanks.  Steve

    Your backups may be corrupted.
    Try to repair them, via Disk Utility (in your Applications/Utilities folder).
    Mount the sparse bundle by opening the TC in the Finder and double-clicking on the sparse bundle. Drag the sparse bundle into Disk Utility's sidebar, and do a +*Repair Disk*+ (not permissions) on it. If it finds errors it can't fix, run it again (and again), until it either fixes them all, or can't fix any more.

  • How can I recover photos from old iphone icloud backup to new one?

    Hello, I had an iPhone 4 which I lost and inside there were some great photos that I want now to recover. In the meanwhile I bought an iPhone5S and I just realized that inside the iCloud backup menu is saying that there is a backup of 3GB of my old iPhone. How can I see if in that backup the photos are there? I have connected my iPhoto App to iCloud but it only finds photos from my new iPhone and not the old one...
    Thanks for your time.

    Hi, Tiago, maybe you can get help from data recovery software. Now things get easy now.
    As far as I know, there are three ways to recover deleted contacts and photos from iPhone 5 with iPhone Data Recovery.
    Way 1: Recover deleted photos from iPhone directly
    Way 2: Using iTunes Backup to recover deleted photos
    Way 3: Using iCloud Backup to recover deleted photos
    You can refer the way 3 of how to recover deleted photos from iPhone to recover photos from  old iPhone iCloud backup.
    Good luck to you.

  • HELP! How can i restore/recover files from Bootcamp with Boot Failure - Missing operating system error?

    Hi,
    I am having a few problems with bootcamp on my imac. When i tried to move the bootcamp partition on windows 7 into free space, it crashed and turned off. Ever since i have had the error 'Missing operating system' and it fails to boot. I have some very important files on the bootcamp partition. Is it possible to recover these files or even to restore the bootcamp partition to it's original state? I do not have a backup of my bootcamp partition. Another problem i have is that ever since i tried to expand my macintosh HD partition into free space, when i hold alt while booting up (to choose which partition to boot like i normally do), the bootcamp partition has stopped appearing. This means that i cannot even boot the windows 7 bootcamp partition anymore!
    So basically here are my 2 questions:
    How can i restore/recover files from Bootcamp with Boot Failure - Missing operating system error?
    How can i make the Bootcamp partition appear in Startup Disk and when i hold the option key while starting up my computer to allow me to boot windows 7?
    Any solutions are very much apreciated!
    Thanks!
    I know that bootcamp (disk0s4) hasn't been fully deleted since it appears in disk utility (i cant do anything to it though)
    And here is the error i see when i try to launch bootcamp (back when i was actually able to boot up bootcamp to the error screen)

    WinClone 3 is OS X and saves Windows image it makes for restore - that should work but you will have to try and you would need to make a new image unless it also works with a native Windows system restore image. It is now supported and has come a long way.
    http://www.twocanoes.com/
    Paragon Clone OS works and does disk-to-disk clone just like CCC you end up with two bootable drives. But does not work with your setup. It would let you clone and move your Windows install to an SSD or another disk drive though and be bootable.
    During its clone process it checks for errors which is very helpful and lets you know - something CCC and others should adopt more of.
    http://www.paragon-software.com/downloads/demo.html
    I wish for our/my sake you had re-read and rewritten the long 'story' and broken it into a brief list of facts we needed.
    OS X
    Windows
    Backup (though external is much safer) and you want bootable OS X clones as well as TimeMachine
    https://support.apple.com/kb/HT1427
    https://support.apple.com/kb/HT1553
    There are a number of things to do like chkdsk and others as well as Windows DVD to do automatic system repairs and find out why.
    AppleHFS - the abilty to mount and read HFS volumes can be notorious.
    I would rearrange and redo your storage setup and how you use the 4-5 internal hard drive bays.

  • Recovering Data from a dead iMac G5

    My iMAC G5 has had it's second logic board failure in the past 1.5 years. The repair shop says it's going to cost $550 to repair, and Apple's not going to cover a 2nd board replacement under the extension program. Given that the computer's 4 years old, and was originally only worth $1200, I think I'm going to get a new Mac.
    My question is, how do I recover data from the hard drive of the old Mac? I don't want to lose all of my files from iTunes, iPhoto, etc. The Hard Drive is apparently fine, but the Mac won't boot up in its current state. Thanks in advance for your help.

    Remove the hard drive and put it in an external hard drive enclosure. Then connect it to your new Mac and recover the files.

  • Recovering data from iphone backup?

    Hey guys,
    I am busting my head over here trying to figure out how to do this.. to make a long story short, I've had a very unlucky past few weeks. My iphone (4g 32gb) fell into the ocean and all the data I had is lost. But then I rememberd I can still recover it from the itunes backup. Ordered a new phone.. the phone just came and before I could do a recovery from it we had a power outage and my laptop got fried. I've been told that the motherboard is fried and since it was an old laptop I didnt bother trying to fix it. (I switched to a MacBook Pro early this year - although the syncing was done on the windows laptop). So.. I took apart the laptop, took the hard disk and connected it to an external USB enclosure. I can access all the data from the hard disk. My question is, can I use this hard disk to do a recovery on the iphone? The old laptop was running on Windows 7. I have access to another laptop with windows 7 & windows xp & mac OSX Lion
    -I've already tried booting from the hard disk, it wouldnt boot.. I keep getting the blue screen of death.
    As long as I can get the contacts, sms's and photos on the new iphone im good.
    Thank you in advance for your feed back!

    I think its time to buy a samsung galaxy... and yes i know that if i would have manually backed up my photos then i wouldnt be in this prediciment, but it all went sound when the backup proceedure that apple build into their products failed.

  • Recovering data from HD ????????

    Hi
    My HD died on my G5 a few months back
    I am wondering if it would be possible to recover data from it
    The situation is this
    I had the idea that maybe if i start up my G5 whilst pressing T & connecting it up to my Macbook Pro via firewire 800 I might see the drives & be able to get files off there
    I didnt see the drives on the desktop but if i opened Disk Uility both drives on the G5 Are there
    They are both displayed as firewire drives each is named with another name underneath which is greyed out
    I can click on each drive but in repair all options "Repair Permisions, Repair disc ETC are greyed out
    I then tried to boot my Macbook pro with the installation disc & using disc utility from the installation CD with the same resut
    Now if i can get this far I should be able to take it one step further & be able to get data from the HD or am i just grasping at straws
    Any Ideas please ??

    A. I would suggest never use CD or DVD.
    B. Setup a disk drive just for repairs.
    C. Get in the habit of using backup like SuperDuper
    If you are running Leoaprd, use TimeMachine in addition to SuperDuper. SD makes an update that is bootable. And you want to insure it works.
    Data Rescue II from Prosoft sounds like a good idea.
    I would pick up a couple drives. A new boot drive, and one for backups, and to recover to. OWC has WD 640GB for $69.
    Only use idential drives when creating a RAID, whether stripped or mirror. And yes, some tests treat the volumes rather than the physical mechanism.
    SMART is not that helpful. When you tested in DW, it wrote to system log and shows how many spare blocks are left, used, which can be helpful.
    TechTool Pro is 4.6.2 (5.0 is out also) and can scan a drive for weak/bad sectors.
    You may need multiple backups. An original system and another of your data. When you used RAIDs you need to be doubly sure. And the best way to use maintenance utility is regularly, preventative medicine.

  • Recovering Data from A WD External Hard Drive

    I have an older IMAC 20 2007- Leopard 10.6 installed and running great. I have a 1tb WD hard Drive via FireWire and a 2tb hard drive via USB 2 as there is no Seta hook up on the IMAC. I also have a 500Gig WD external hard drive that has a lot of saved movies and programs on it. I Want to recover the movies on the 500 Gig. to the 2 tb or teh 1 tb hard drive. The problems is, when the IMAC recognizes the 500Gig Hard drive it will not copy the movies over as it says "they are in use and cannot be copied" OR the IMMAC will not recognize the 500Gig drive at all, it says the hard drive is not recognized. The movies were copied to that hard drive with the IMAC Why can I not recover them from the Hard Drive? I assume that the hard drive may be on its way out. Does anyone know how to recover those files? Mostly Movies MP3s and some programs. Thank you

    Install OS X for emergency use so you can do repairs and maintenance, on another drive.
    Some iMacs can, at least now, maybe retrofitted, have an eSATA controller added. Yes, shame there is no ExpressCard slot of native external SATA ports.
    USB2 is slow and terrible interface for today's drives, real need for USB3 drives.
    Tried Data Rescue 3 demo?
    How about a full volume clone operation with SuperDuper or TriBackup 5, or Carbon Copy Cloner?
    WD MyBook units can be Mac-unfriendly and trouble, there are Mac specific models of WD MyBook or there are other makes that do work, usually use the Oxford chip bridge to provide USB/FW/eSATA.
    Maybe there are errors with file system, data, or even the drive directory causing problems.
    Do the external drives have their own power supply? should.

  • Recovering Data from a truncated table in OraXE?

    A funny thing happened, i truncated a table containing BLOBs and other stuff, with over 700 entries!!, now i wanna know if it´s feasible to recover that truncated data, i'm just wondering about it, i know it sounds silly i know, but the storage space didn´t get shorter after the data was truncated from the table, so after this´s been said, can any body explain me what happened, can i retrieved this truncated data that i truncated from the table (without any previous backup)?
    Message was edited by:
    efebo_abel2002
    Message was edited by:
    efebo_abel2002
    Mensaje editado por:
    efebo_abel2002

    Truncate simply resets the pointer that marks the 'end of data' in a table to the beginning of the table. The storage is still allocated, on the assumption that you want to reuse the table and want to avoid the overhead associated with extending the table. The system knows there are never any rows past the 'end of data' and it won;t bother looking past that point.
    Recovering that data from the actual current database - about as likely as recovering data from the Windows recycle bin when you've set the max allowable storage in the recycle bin to '0'. Technically possible, but needing someone with a lot of experience and patience ... and absolutely no changes to the database after truncate. An expensive proposition.
    You have, of course, switched to archive log mode and been taking regular backups. (Have you not?) In which case, a 'point in time' recover, to just before the truncate, would be the solution. This brings back the database (or at least a tablespace) back to a former 'life', and is quite different from restoring a table.

  • Recovering data from a newly formatted hard drive

    Has anyone had any experience with programs that recover data from a newly formatted hard drive?  There seem to be a lot of programs out there to do this, but, a) do they work, and b) which one worked best for you? 

    Ive had so and so success with a freeware utility called "Recuva"
    http://www.recuva.com/
    Its from the makers of CCleaner.
    *******DISCLAIMER********
    I am not an employee of BBY in any shape or form. All information presented in my replies or postings is my own opinion. It is up to you , the end user to determine the ultimate validity of any information presented on these forums.

  • How do I recover data from a repartioned boot drive?

    Hello all, I am hoping someone can help me with my problem. I have a PowerMac G5 1.8 single CPU. OSX 10.5.
    Recently my 'B' hard drive dedicated to Time Machine failed. I purchased a replacement drive, and when in disk utility I accidentally repartioned my 'A' drive. So now there is no startup disk. Can I reverse what I did? I am thinking no.
    I have Data Rescue by Prosoft, and I scanned it and I can recover all from the A drive (it's about 2 TB for everything). But I don't need to recover the OS since I have the disk. I just want all my data.
    So here are my questions:
    I don't have a 2TB drive. I could purchase one and recover all the data from the A drive. Then what do I do? I assume I would reload a fresh install of 10.5 onto the new B drive (saving A for now). Then how do I get all of my files and setting backs into the new boot drive? Is there an easy way to reimport?
    If I don't buy a 2TB drive, what are my options? Again I assume I would load fresh 10.5 onto B, then try to recover the files I need from the old A drive. I have tons of photos, emails, and some PShop and Illustrator work files.
    What happens of I reload 10.5 back onto the A drive? Will it wipe out all of the files I want to save, or is OSX smart enought to keep data and only install the OS?
    Are there any other options for me?
    Thanks,
    Neal

    nealfromhillsborough wrote:
     Run Data Rescue and cherry pick the data off the original A drive onto the new boot disk B.My fear is that I am not savvy enough to filter through all the files I don't need to find what I do need, and then knowing where on the new drive to put it.
    Safer to recover everything that's recoverable, then pick out what you want, and ensure it's usable.
    Oh, another question. Let's say I get the new 2TB drive and recover everything, does that mean it become a bootable disk again? Wiil it behave like the original A did? I understand there will be some damage, I'm just not clear (and Data Rescue's literature is not clear) on what happens after a full recover. I guess it will just be folders/files that I need to review for what I need.
    No, it won't be bootable; you'll just have a data disc.

  • How can I recover files from an iPod Touch (4th gen) prior to a required restore?

    How can I recover files from an iPod Touch (4th gen) prior to a required restore?
    The iPod Touch was working perfectly fine.  iTunes suggest that I update the iPod Touch to the latest operating software, and I proceeded to do so.  Then a message popped up stating that the iPod Touch needs to be fully restored - and that all data will be lost.  The iPod Touch now displays the 'plug into iTunes' screen, and is stuck there.  There are irreplaceable family momentos on the iPod Touch.  How can I recover files from an iPod Touch prior to a required restore?  HELP...

    Your only hope is to contact a data recovery company. When it shows the connect to iTunes screen the iPod is essentially deleted.
    You can restore from an existing backup

Maybe you are looking for