Power failure and FileOutputStream behavior.

Hi,
In our application, we use FileOutputStream to write binary data to a file. We perform a out.close() to close the file. However, if there is a power failure, the data is not written out.
We created a simple test utility, which writes out 1K file containing 256 sequences of the string 'abcd'. After the close, we did a sleep(60000) to sleep for a minute. Everything works fine in the normal case. If however there is a power failure (pull the power cord), after the close() but before the sleep() expires, the file is not written out. We get a file of either zero bytes or sometimes a file of 1024 bytes, all of them being zero. The JVM sis the SUN JVM 1.4.3_08
The following is a simple class.
import java.io.File;
import java.io.FileOutputStream;
public class FileWriteTest {
     public static void main(String args[]) {
          if (args.length < 1) {
               System.err.println("Usage: <file> <wait-time>");
               return;
          final String filename = args[0];
          final byte[] buffer = new byte[1024];
          int waitTime = 60 * 1000;
          if (args.length == 2)
               waitTime = Integer.parseInt(args[1]);
     for (int i = 0; i < 256; i++) {
               buffer[i * 4 + 0] = 'a';
               buffer[i * 4 + 1] = 'b';
               buffer[i * 4 + 2] = 'c';
               buffer[i * 4 + 3] = 'd';
     try {
                    java.io.OutputStream out = new FileOutputStream(new File(filename));
                    out.write(buffer, 0, buffer.length);
                    out.close();
                    Thread.sleep(waitTime);
          } catch (Exception e) {
               System.err.println("Exception: " + e.getLocalizedMessage());
               e.printStackTrace();
               return;               
Thanks.

FileOuputStream doesn't do any buffering so what you are seeing is the behaviour of your operating systems. They usually defer writes so they can be consolidated and performed at convenient times for the disc controller.

Similar Messages

  • I had a power failure and for a number of websites why do I now get the message "This Connection is Untrusted."

    After rebooting after the power failure when I go to new websites or even within some websites after clicking on a link the message box appears and I have to add a security exception to get past the message and see the link. I am using V4.0. I do not get that message on another computer using V 3.6.15.
    What can I do to reset the browser?

    John,
    That did it! I no longer get that message. The clock was set to the wrong day and time. So far it is keeping time correctly, but per your suggestion I will also check the battery.
    Thanks for the prompt and accurate help.
    H Weiss

  • Commercial power failures and FiOS service interruptions

    Severe weather reminder for our FiOS customers...
    In the event of a commercial power failure, your FiOS battery backup will power your standard voice service for approx 8 hours. For additional information about the battery backup unit, click here for more info.
    It’s possible that after electrical power is restored, you may still be without FiOS TV service. Sometimes resetting your Battery Backup Unit (BBU) is needed. Click here for more info.
    For an automated wizard to help with FiOS restoration, click here.
    Due to extreme weather conditions, there may be storm related power outages in your area.  Your FiOS services will be affected until power resumes.  If you do not have power please contact your local power company.  If your power is restored and your FiOS services are still not working, you can report an outage, check status, request a new repair or update an existing repair online at www.Verizon.com/repair .  If some of your Verizon services are working, but not all, you can use the In Home Agent application on your PC to troubleshoot and restore services.   We apologize for any inconvenience.

    when you lose power, the BBU kicks in, and after  minute or so, the video and data ports will be shut off at the ONT at your house to save battery power.... the battery is ONLY for the phone
    In the event that the Verizon CO lost power/signal and you truly had no signal coming to your house.. then all services would go down
    Bob Robertson - Lighter Klepto - I steal lighters, not bandwith

  • Power failures and the WRT54GL

    I have a WRT54GL. Yesterday, there was a series of three power failures where the power was restored within a split second. After this, I noticed that the Internet connection was down and that the power LED was flashing, which usually happens when the firmware is corrupt, as seen here: http://linksys.custhelp.com/cgi-bin/linksys.cfg/php/enduser/std_adp.php?p_faqid=3703. After I power cycled my router, the router worked fine. However, I am worried if the somewhat frequent power failures in my area could brick it. The electricity from Progress Energy, the local electrical utility in Cary, NC where I live, fails approximately once every one to three months, often enough that WRAL-TV did a story on the frequent power failures last year. However, all of the power problems have been failures and not power surges. Are my worries justified that Progress Energy could brick my router with its flaky power?
    Message Edited by jnv11 on 03-10-200709:14 PM

    Hmmm.. try to buy a UPS to avoid problems during power outtages...

  • I have had my ipad for 6 months. We had a power failure and ever since my ipad will not charge with the wall adapter that came with it.  It will SLOWLY charge when plugged into computer port. Can anyone help me resolve this?

    I have had my iPad for 6 months.  We recently had a power outage and my iPad was plugged in with the adapter that came with it.  Since then I can not charge iPad with adapter, however I can charge it SLOWLY on my computer.  Do you think the adapter got fried?  Also do you HAVE to have iTunes with an iPad, they were charging me alot of fees for games I did not download NOR give my password to have them downloaded so I cancelled iTunes because fo too many fees. Could this have anyting to do with the battery not charging?

    Since then I can not charge iPad with adapter, however I can charge it SLOWLY on my computer. 
    Well, something's definitely wrong if it won't charge from a wall outlet. Make an appointment at a Genius Bar or take it to an Apple certified repair provider.
    As for iTunes charges, according to Apple  iTunes Store: All Sales Are Final
    You can try contacting iTunes Billing:
    http://www.apple.com/support/itunes/
    Click: iTunes Store Account & Billing / Billing Inquiries / Email Us

  • Power Failure and eMac won't come back on

    We had a thunderstorm and the power went out. Not the first time, but even though the eMac was plugged into a surge protection bar, it will not turn on. Any ideas?
    Thanks,
    Chris

    If the PRAM battery (or whatever they call it now) is nearly dead, this will often keep the eMac from booting back up. Usually you will noticed in previous power downs and restarts you may get a message about your clock and date being set wrong. This is a sign your battery is dead. Eventually it gets tot he point where it actually prevents the Mac from starting.
    So unplug the eMac, flip it over, open the door on the bottom where the RAM and battery are. Remove the battery. Put the door back on. Flip it back over. Plug it in and try to start it. If it starts up, then that was your problem. Take the little battery to your local Radio Shack, Best Buy, Comp USA, whatever, and get a new one. In the meantime you should be able to use your computer. Sleep it instead of shutting it down until you get a new battery.
    Good luck,
    Patrick

  • Power failure and lost Pages file

    Power on my laptop suddenly went off and I had not saved a copy of a new Pages file I was working on. It does not appear in recent files or anywhere when I restarted and opened Pages. Are temp files stored anywhere that I might look to recover the work I've done?

    Mark,
    No, unfortunately.
    You can set Pages to save a copy of any +previous version+ in your Preferences, however this wouldn't help in this case.
    Download (free):
    http://www.macupdate.com/info.php/id/29454/eversave
    To autosave everything you wish in your Mac.
    Best is to use cmd S regularly as you work, then you choose at what point it is saved.
    Peter

  • Installing update we had power failure and system will not boot

    We do not have a current working back-up, how do I re-install the os w/o erasing the entire hard drive?  We have a Intel Imac with snow leopard on it.

    Thanks for the info.  This is my fathers machine and I am the one that gets stuck fixing it when he has problems. I used to be an Apple Certified Repair Tech in 99/00 but that seems like a life time ago now.
    The system came with 10.5.  We upgraded to SL and have the disk and then to Lion which was a downloadable upgrade correct?  I will take a look at the link you sent.
    Thanks,
    Matt

  • We had a power failure and after the pc rebooted Firefox would not open. Several attempts were made. So I uninstalled the program and tried a reinstall. No joy.

    The registry was cleaned of every reference to Mozilla. Again the reinstall was tried with no success

    There is probably a problem with the profile folder, which is where user data is stored.
    Try creating a new profile folder as shown here - http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
    If the new profile folder works, you can selectively copy data from the old profile folder such as bookmarks and passwords. For details of the files to copy see https://support.mozilla.com/kb/Recovering+important+data+from+an+old+profile

  • ITouch 'sync' - household power failure - iTunes prob

    My iTouch was trying to sync before a household power failure and the computer teellback states 'This iPod cannot be used because the Apple Mobile Device Sertvice is not started'

    See this Apple support document.
    http://support.apple.com/kb/ts1567
    B-rock

  • Problem with iMacs loading web pages slowly after a power failure

    We have 3 intel Macs (2 iMacs and a MB) on our network.
    Today we had a power failure, and now we are having problems with both iMacs loading some web pages slowly (in Safari and Firefox both). I have shutdown and restarted both iMacs to no avail. As you will notice, I have not experienced any problems with my MB probably because the battery never allowed it to shut down completely.
    Can you give me any indication of what the problem is or how I can go about troubleshooting this further?
    Thank you in advance.

    It does sound like it could be a WiFi issue. You can try rebooting your router and that might help. It just might your Internet connection or the router itself. If the router is bad, you can replace it. If its the Internet connection - you can only do what you ISP allows you to do.

  • Power failure then iPhoto library= POOF! :-(    PLEASE HELP!

    Power failure then iPhoto> library= POOF!
    We had a power failure and of course iPhoto was open when my computer was improperly shut down. After powering up, I did the following; repaired permissions and ran disk utility (no problems found).
    Upon opening iPhoto (6.03) I got the rebuild thumbnails message, and I said cancel (I was going to do it later), then IPhoto opened and it was BLANK! all 5000+ images were GONE! I am assuming the library got corrupted somehow on either the bad crash, or the canceling of the rebuild option.
    Now, I am a bit neurotic about my pics, so I choose to make my own finder folders of pic when I take them off the camera, and then import into iPhoto that way. So the good news is I still have all my original pictures in folders in the finder.
    From reading various threads here, and Googleing + Macfixit, etc etc. This is what I have done to try to recover my library. (not necessarily in this order)
    [list]
    [*]Trash/recreate the iPhoto plist preferences
    [*]Clear caches using Cocktail software
    [*]Repaired permissions (in Disk utility), and then repair iPhoto library folder permissions usuing instructions found here using Batchmod software
    [*]Rebuild the iPhoto library (option, command) and selecting the 3 proper checkboxes.
    [*]Ran iPhoto Library Manager software to rebuild the database with no success. I get the error message "This Library cannot be rebuilt because its XML file contains no data".
    [*]Updated to iPhoto 6.04/repaired permissions and disk utility.
    [/list]
    Each time iPhoto loads completely blank and void of my photos!
    My assumption is the XML file is corrupt since I am getting that message in iPhoto Library Manager.
    So what to do? And hear are my questions /issues.
    I would certainly like to preserve my 4 years of customization of keywords, titles , folders, smart folders, etc. (which I assume is held in the now corrupt XML file?).
    What is the best way to recover my customization and most importantly the images!
    I realize I can just re-import all my images from my original finder image folders that I have, but I assume this method will not recover my keywords ,etc?
    Is there a way to recover my customization?
    I do have a fairly recent backup of my iPhoto folder on a backup drive ( I think!) It does not have all my newer pics in it, but as I mentioned I do still have all my .jpgs, just not in iPhoto!
    Thanks in advance for reading and any help offered!
    PBG4 1.33 2gig   Mac OS X (10.4.6)   120 gig hd

    I got all my pictures AND everything else back, folders, ratings, keywords etc
    Fortunately I had a backup of the entire iPhoto library folder, it was about 3 months old (I know shame on me) so I didn't want to just use the entire backup folder and lose 3 months of photos.
    So I just copied the AlbumData.xml file and the Library6.iPhoto file. PRESTO all my pictures were back WITH all the folders,keywords etc, etc intact!! (up till the 3 month old backup point).
    Then I just re-imported the missing 3 months worth of pictures from the original folder in the iphoto library folder. So all I had to recreate was 3 months worth of customization. WHEW!!
    Reading through the discussions it seems there is a fair number of users where iPhoto would go empty, but they knew the images were still on the computer. I am not a programmer, but it seems silly to me the their are files that get re-written everytime iPhoto closes....computers crash. and then what happens to the files? Mine got corrupted, lesson learned BACKUP more frequently!!
    Thanks to Old Toad who steered me to the Library6.iPhoto as a possible troublemaker in another thread!

  • Domain controller VMs using dynamic VHDx corrupt after power failure

    Over the past couple of months I have experienced 4 dead 2008 R2 SP1 domain controllers after power failure on Hyper-V 2012 hosts. The domain controller VMs will start after power failure and have varying degrees of file system corruption. In each instance
    the corruption has rendered the domain controller unusable. The problem has not occurred with every power failure, but in testing the failure rate has been over 10%.
    The Hyper-v 2012 hosts are as follows:
    Dell PowerEdge r720 with flash backed write cache on Raid controller
    Dell PowerEdge T710 with battery backed write cache on Raid controller
    Dell PowerEdge T310 with a single SATA hard drive and write cache disabled
    Generic system with a single SATA hard drive and write cache disabled
    The VM configuration experiencing corruption is as follows:
    Each VM was created from a base 2008 R2 SP1 syspreped VHDx image template file (40 Gigs)
    The image template was originally created as a VHD and was then converted to a VHDx
    The VHDx file has 512k sectors instead of the native 512e of VHDx files (a result of VHD - VHDx conversion)
    Each VM was assigned 1024 Meg RAM and 1 virtual processor
    The domain controllers were created by promoting the base 2008 r2 install to a DC after base image deployment
    Only one corrupt VM was not running the 2012 integration components. The rest were running current 2012 integration components
    I have done extensive testing on this issue and the problem for me seems to revolve around the VHDx file format. I have managed numerous Hyper-v installations since the original 2008 server version was released and I have never seen corruption like this
    until 2012 and VHDx.
    For the past few days I have been testing fixed sized VHD VMs on a 2012 host and I have not been able to reproduce the data corruption issue. I seem to only be able to reproduce the problem when using dynamic VHDx files. I have not done any testing on 2012
    hosts with fixed size VHDx files or dynamic VHD files.
    It would be great to hear from anybody else experiencing similar issues so that we can compare notes and hopefully get to the bottom of this problem.

    To be honest I was excited to see this fix released, but there are two problems.
    1. The hotfix causes BSOD if you have VLANs with a teamed NIC configuration. I found this out the hard way on a production system. How in the world did this thing get through testing and into automatic updates?
    2. The hotfix does not seem to resolve the issue in my test environment.
    I opened up a case with support and they informed me that they would not provide support for this issue and that I had to open a case with premier support. Premier support informed me that I cannot open a case with them unless I sign a $50,000 per year service
    contract. Is there anywhere to get support on this issue?

  • [Solved] KDM will not open after power failure

    Had a power failure and upon reboot, I get the following error:
    cannot open theme file
    /usr/share/apps/kdm/themes/archlinux-simplyblack
    I cd'd to the above path but only 'circles' and 'oxygen' are in the themes folder.
    I even ran pacman -S kde to reinstall all the kde packages, but no luck.
    Any ideas on a fix?
    Thanks!
    Last edited by SkinnyJ (2009-05-05 02:15:53)

    glad it works now, if you're using ext4 i hear power failures can corrupt some files; otherwise, i dunno.
    anyway, please mark as [solved].  and thanks for the bit about my enemies .

  • New Server 2012 -- Network Location Awareness & Power Failure

    Could you try setting up a dependency or delay on the boot? This would be more of a temporary solution, but should help you confirm that the only issue was with communication with the DC.

    Hello everyone,This is kind of a mixed question of AD/Domain/GPO, Server 2012 R2 Standard, Windows 7 clients, and File Sharing.. please bare with me.We had an interesting event this morning..We have a 2012 R2 STD member file server on the domain. We had a total power failure, and I believe the file server came up faster than any domain controller. Anyhow, we couldn't access the shares on the server. Upon further investigation, I saw that the network location on the file server was 'unknown' and decided to restart the server. After that, it went back to its domain profile.Are there any known solutions to this scenario? Can I force the server to use the domain profile at all times? I've briefly read about the local GP edit trick, but haven't tried it out yet. Apparently, you can allow changes to adapter profiles, and then manually set...
    This topic first appeared in the Spiceworks Community

Maybe you are looking for

  • Unable to create a 'Z' for se16 transaction

    Hi everyone, we have a requirement where we are unable to create a Z for transaction SE16. I went to se93 and checked it was a function pool so i went to SE80 to make a copy of standard function group SETB to ZSETB. it made a copy of it anf I copied

  • Caldavd failing to start after upgrade to Server 3.2.1

    This problem, caldavd not starting after upgrading to Server 3.2.1, is a variation on the theme of PostgresQL not starting.  It too boils down to a postgres database not having been updated properly.  Below are the steps needed to fix this problem: s

  • How does LabVIEW convert string to char* when passing them to a Call Library Node?

    I have a program which calls C++-based libraries which themself use external libraries (Qt). I pass strings to my library through the Call Library Node, and was wondering how the formatting goes? I have to interpret the char* according to Latin1, UTF

  • Can't update Dreamweaver

    I have Dreamweaver MX 2004 and I downloaded an update for the application. When I tried to update it, the updater said it couldn't find the application file in the folder that was selected... yet the file is there! Any ideas as to what is wrong?

  • Acrobat XI will not install

    I downloaded Acrobat XI standard.  It hangs when I try to install it.  It getsto Windows Installer and says it is preparing to install and that is where is stops working.  What is wrong.