FileInputStream.open deletes file

We are currently seeing some very strange behavior from FileInputStream.
Our sample app creates a FileInputStream, passes it into another function which copies the file to a temp directory and file. That temp file is then opened by a child process, which reads data from the file, but doesn't modify it. The original input stream is not used anymore, and unfortunately, is not closed either (not my code, a customer's....)
After repeating this process many times (hundreds), the creation of the FileInputStream fails. Turns out that FileInputStream.open() deletes the file!!! We can step into the FileInputStream code, and the file still exists just before the call to open(). The call to open() fails and throws a FileNotFoundException.
This is blowing our minds. Why would FileInputStream delete the file, under any circumstances? And why would this only happen after repeating the process hundreds of times? We have tried calling fin.close() to correct the customer's error, but that seems to make no difference. Any help with this is greatly appreciated.
Environment:
Win2000
JDK 1.4
Thanks,
Mike Ryan
Stellent, Inc.

OK, we found out a little more. We are registering a shutdown hook to watch the child process that is created. That hook only serves to kill the child process if the JVM is suddenly shut down. We add it to the Runtime, then wait for the child process to finish, then remove the hook.
For some reason or another, removing the code that adds and removes the shutdown hook makes this work just fine. This makes no sense, since the shutdown hook knows nothing of our original input file.
Anyone have any ideas what could be going on?

Similar Messages

  • FileInputStream.open deletes my file

    FileInputStream.open deletes my file and throws a FileNotFoundException.
    i am running a java process on machine 'B' to copy a file from machine 'A' to machine 'B'.
    In windows ('B') i get an error message when trying to copy the same file from 'A' to 'B': "Cannot copy file.ext: Access is denied. The source file may be in use."
    i use the following code to copy the file:
    File f = new File("P:/file.ext"); // where P: is a mapped drive
    System.out.println(f.exists()); // this always prints true
    new FileInputStream(f); // i get ex here
    at the same time i get the exception, the file is deleted from P:
    any ideas?

    yeah, it seems very intermitent. it seems to only happen when a file is in a bad state (according to windows on machine 'b'). the machine the file resides on seems to think the file is fine tho.
    i really need to know why the file would be deleted instead of throwing some sort of 'BadFileException'.. any IO experts out there?

  • I am trying to delete pages from a PDF file. I opened the bookmarks, selected the pages to delete and choose Edit Delete. The selected pages are not deleted. Note: I have to open the file using a passport provided by an external party.

    I am trying to delete pages from a PDF file. I opened the bookmarks in the PDF file, selected the pages to delete and choose Edit > Delete. The selected pages are not deleted. Note: I have to open the file using a passport provided by an external party.

    Resolved

  • Deleting email on outlook opens a file download from firefox

    deleting email on outlook opens a file download from firefox

    Windows 7 - Outlook has a file download box that will not go away.,please help
    go to this website and the solution is there...
    http://www.sevenforums.com/microsoft-office/176965-outlook-has-file-download-box-will-not-go-away-please-help.html

  • I cannot open pdf files in safari.  It tells me first character is invalid.  I have deleted plug-ins and reinstalled program.  HELP

    cannot open PDF files in safari.  It tells me first character is invalid - I have deleted plug-ins and reinstalled the program.

    HI..
    If you are using Adobe Reader ...
    Try uninstalling the current copy of Adobe Reader first.
    Best to use a utility to do this to make sure all the associated files are removed as well >  Download AppCleaner for Mac - Uninstall your apps easily. MacUpdate.com
    Then reinstall >  http://get.adobe.com/reader/
    Quit then relaunch Safari to test.

  • Delete files in Open Recent Files list - CS3

    Is it possible to delete single files in the "Open Recent Files" list
    or specify how many recently opened files are be shown?
    I am using CS3 (5.0.3).
    Thanks

    No and no, although Adobe themself doesn't seem to have any problems with this -- every single update kills the list (to my chagrin).
    Can't imagine any bona fide reason you'd want to. It's not like it's meant as sort of kind of Document organizing feature, as if.

  • Entourage will not allow Delete file messages to be opened and deleted

    I have allowed my delete to get to large. Now Entourage won't allow Delete file to be opened; when attempted, it says, "file cannot be opened, not enough memory". How can I open to Delete file to delete messages?

    You should be able to check by opening the Attachments panel on the left (paperclip icon) and looking at the file extension.

  • Copy File, Delete File & Opening Document

    Hi All
    Please help, note that I use JDK 1.1.7A. I have 2 directories I recieve a file into the first. This kicks of a process, when the process is finished I must take the file and copy it to the 2nd directory. Once it is copied I have to delete it from the 1st directory.. I then check through my explore from windows to see if I can open the document after it had been copied. I get an error from Winword that kinda says the following:
    Document Name or path is not valid. Try these sugestions. Check file permissions. Use OPen Dialog box[]
    private boolean copyFiles(String sFrom, String sTo, String sCopyList)
    File fFrom = new File(sFrom);
    File fTo = new File(sTo);
    String sParent = "";
    if (sCopyList.equals("PCIError"))
      sParent = fFrom.getParent();
      fTo = null;
      fTo = new File(sParent, sCopyList);
    int iNoToCopy = 0;
    File fTempRead = new File(fFrom.getAbsolutePath(), sCopyList);
    File fTempWrite = new File(fTo.getAbsolutePath(), sCopyList);
    if (fFrom.canRead())
      try
       RandomAccessFile randomWrite = new RandomAccessFile(fTempWrite, "rw");
       RandomAccessFile randomRead = new RandomAccessFile(fTempRead, "rw");
       long fLength = 0l;
       if (fTempWrite.exists())
        fLength = fTempWrite.length();
        randomWrite.seek(fLength);
       //FileReader fRead = null;
       //String sRead = fFrom.getPath() + File.separator + sCopyList;
       //fRead = new FileReader(sRead);
       //BufferedReader bufRead = new BufferedReader(fRead);
       String s = null;
       while ((s = randomRead.readLine()) != null)
        randomWrite.writeBytes(s);
       //bufRead.close();
       randomRead.close();
       randomWrite.close();
       fTempRead.delete();
       File fDelete = new File(fFrom, sCopyList);
       fDelete.delete();
      catch (IOException ioE)
       ioE.printStackTrace();
       return false;
    return true;

    Hi All
    I though that I had this problem resolved Alas I don't. If I have 2 existing directories than it works fine. When I have to create a new directory then I run into some problems. File creates a file. You then use the mkdir() method to make that file into a directory. It does not work the system creates the file but then doesn't turn it into a directory when that method is called.
    Here is the code:
    private boolean copyFiles(String sFrom, String sTo, String sCopyList)
         File fFrom = new File(sFrom);
         File fTo = null;
         String sParent = "";
         boolean bDir = false;
         if (sTo.endsWith("PCIError"))
              sParent = fFrom.getParent();
              fTo = new File(sParent);
              bDir = fTo.mkdir();
         int iNoToCopy = 0;
         File fTempRead = new File(fFrom.getAbsolutePath(), sCopyList);
         File fTempWrite = new File(sTo, sCopyList);
         if (fTempRead.canRead())
              try
                            //This is where the IOException is thrown
                   RandomAccessFile randomWrite = new RandomAccessFile(fTempWrite, "rw");
                   RandomAccessFile randomRead = new RandomAccessFile(fTempRead, "rw");
                   long fLength = 0l;
                   if (fTempWrite.exists())
                        fLength = fTempWrite.length();
                        randomWrite.seek(fLength);
                   byte by[] = new byte[500];
                   int byteread = 0;
                   randomWrite.seek(0);
                   while ((byteread = randomRead.read(by)) != -1)
                        randomWrite.write(by, 0, byteread);
                   randomRead.close();
                   randomWrite.close();
                   fTempRead.delete();
                   File fDelete = new File(fFrom, sCopyList);
                   fDelete.delete();
              catch (IOException ioE)
                   ioE.printStackTrace();
                            //what is printed out to my console:
                            /*java.io.IOException
                           java.lang.Throwable()
                              java.lang.Exception()
                           java.io.IOException()
                           void java.io.RandomAccessFile.open(java.lang.String, boolean)
                           java.io.RandomAccessFile(java.lang.String, java.lang.String)
                           java.io.RandomAccessFile(java.io.File, java.lang.String)
                           boolean pci.Pci.copyFiles(java.lang.String, java.lang.String, java.lang.String)
                           void pci.Pci.run()*/
                   return false;
         return true;
    RESULTS
    I want to create in a directory PCIError as File folder in directory:
    E:/Applications/.
    Thus it must look like this:
    E:/Applications/PCIError.
    I want PCIError to be a File folder. But instead I get the following: E:/Applications/PCIError and PCIError is not a File folder but just a simple file that is not a directory at all so I can't copy any files into directory:
    E:/Applications/PCIError
    Because it isn't a directory but a file.
    I would appreciate any help possible. Please also remember the version in which I have to write this program it is not an option to change the JDK Version.
    Regards & thanx

  • How to open files with "return" key and delete files with "delete" key?

    Hi friends,
    It's been over a week since I got my iMac and I'm loving it. However, while I'm adapting alright to 'mac' key shortcuts (e.g. using the COMMAND-S for save as opposed to CONTROL-S used in PC).
    However, there are 2 things that are annoying me greatly right now.
    1. I like selecting files with keys as opposed to using the mouse. I make animations and prefer keyboard shortcuts. However, when I hit "return", instead of opening the file it goes into file-renaming mode. How do I change this? Likewise, I would like to delete files by hitting the delete key. This does not work - how do I change this?
    2. When I click SHIFT key sometimes, it gets 'stuck' - which is annoying because I start typing CAPITALS when I wasn't aware I've activated the CAP-LOCK key. How do I get rid of this? Like, I don't want to hit SHIFT for instance, and have that up arrow thing 'stuck' there.
    Your help would be greatly appreciated! Thanks!
    iMac G5   Mac OS X (10.4.9)  

    Hi
    Thanks for the star.
    If you went into Mac Help & searched, 2 results come up:
    Full keyboard access shortcuts for interacting with items (for selecting & activating controls).
    Full keyboard navigation keyboard shortcuts (for navigating Desktop, Windows, Menu bar etc)
    From the lists, select the link that closely describes your situation.
    I have to say that I can't reproduce your problem, does this happen just in applications or in everything? I don't know if it's to do with this but pressing Shift 5 times turns on Sticky Keys & Option(Alt) 5 times to turn on Mouse Keys (System Preferences>Universal Access>Keyboard).
    After typing "Sticky Keys" into Mac Help, I found this:
    "Pressing a group of modifier keys as a sequence
    To perform many tasks on your computer, you need to press one or more modifier keys (Shift, Command, Option, and Control) at the same time as another key. For example, pressing Shift-Command-Q in the Finder opens the Logout dialog.
    If you have difficulty pressing several keys at once, you can make it easier to press a set of keys by turning on Sticky Keys in the Universal Access preferences pane. With Sticky Keys turned on, you can press a set of modifier keys as a sequence. As you press each key, the symbol for the modifier key appears on the screen.
    Choose Apple menu > System Preferences and click Universal Access. Then click Keyboard.
    Select the On button next to Sticky Keys.
    To hear a sound whenever the computer registers that you have pressed a modifier key, select "Beep when a modifier key is set."
    To see an icon indicating which modifier keys you have pressed, select "Display pressed keys on screen."
    You can also use Slow Keys to adjust the amount of time between when you press a key and when it is activated."
    Any of this close to your problem?
    Steve
    Edit: I'm right, it's Sticky Keys:
    http://www.macusenet.com/190284-post2.html

  • Hi there, my iMac has automatically been deleting files from my thumb drive when I try to open them.  The lost files aren'tin the trash or anywhere else I can think of.  Any ideas?

    Hi there, my iMac has automatically been deleting files from my thumb drive when I try to open them.  The lost files aren'tin the trash or anywhere else I can think of.  Any ideas?

    If one drive works and the other doesn't that points the finger at the errant drive. They are cheap, replace it. To check formatting right click it in Finder and choose Get Info and look for Format type. Finally do you eject it when removing it or do you just pull it out of the USB connection?

  • I am trying to open space in my macbook hard drive, so I deleted files and after emptying the trash bin the amount of Gigs didn't increase, why? Where can I go and delete those files?

    I am trying to open space in my macbook hard drive, so I deleted files and after emptying the trash bin the amount of Gigs didn't increase, why? Where can I go and delete those files?

    Did you do a secure empty trash? SHIFT COMMAND DELETE, they will be over wriiten. Are you deleting docs as they aren't much space, videos,pictures,music use much more space.
    You can move those fiels to an external "archive" drive to save them then delete them from your internal drive.

  • When I open my files to download my pictures from my iphone 6 plus, there is a windows icon with a hard drive.  What is that? And why can't I delete it?

    When I open my files to download my pictures from my iphone 6 plus, there is a windows icon with a hard drive.  What is that? And why can't I delete it?  I already reset my phone and a week later they came back. 

    I download my pictures by:
    !) Connecting my iphone to he computer.
    2) It will open a window or I will go to my computer and select iphone device.
    3) Open up Iphone folders and download.
    When I do that, I see a windows icon, with what looks to be a hard drive.  And when I click on it, it leads me back to my desktop.  Right now, I only have one.  I know by tomorrow I will have more.  It just keeps spreading. 

  • I deleted files coldnt open like .jpg,pdf.part

    file name unknown and couldn't open or (didnt realize they may have been important )so like a fool i deleted them .jpg,pdf.part,png,gif,ps exe and so forth now i am afraid these were part of the computers programming.. i am new and am so worried, thought i was cleaning junk what do i do now? trash emptied will i ever know what i deleted?

    Hi,
    Some Info.
    First click anywhere on the Desktop that might be visible around anything you have open.
    The word Finder should now appear in the menu bar.
    Click and hold this to see the menu and select Preferences.
    In the Preferences Window that shows up select Advanced.
    Select (Tick the check box) the option to Show All File Extensions.
    When this is done all the files on the computer will display their relevant .something ending (Extensions).
    So most things in the Application folder will now show ApplicationName.app
    In the Pictures Folder you will see different ones (if that is where your Picture files are)
    .jpg .tif, .png .gif
    Some of these such as .jpg or .gif and .tif are fairly universal meaning many apps can open them
    .pdf files can be opened by Preview and Adobe Reader as they are Portable Document Files (PDF) and needs a PDF reader. (they can be a mixture of Picture and Text like a word processing cocument)
    You will notice in my Pic I have ones ending in .psd
    These are saved from the Photoshop Graphics app.
    This leads on to the next point.
    Most apps will save Files with an ending that in most cases only they can open.
    For instance iChat can be set to Save Transcripts.
    these are stored in your Home Folder/Documents/iChats in dated sub folders.
    You will find they end in .ichat
    TextEdit  can save in two formats (file Extensions)
    .rtf (Rich Text File) or .txt (Plain Text FIle)
    Ususally in a file name there is only one . (dot) before the end.
    So the way you wrote .jpg.pdf etc. would not exist  (there are of course exceptions)
    Double Clicking a file will normally get the App that created it or the nearest thing you have that can open it to Launch and then show you the file.  (There are ways to Control which app opens which files but that is another lesson)
    If this does not work you can go to the Finder's File Menu and use Open With - which will present you with a list of apps that can open a file.  (Often this will include Browsers as they often have Plug-ins that deal with the Pics on web sites - Safari for instance includes a PDF reader)
    .js does stand for Javacsript.
    This is used on Web sites to help with functionality. 
    It would be unusual to download this unless you were downloading something for a web site about building web sites.
    On most web sites the Javascript is a separate file that the page accesses when needed to do a specific thing. Sometimes though small short exerts of javascript may actually appear on the page (When looked at in Source view).
    It is similar with .css (Cascading Style Sheets) that many web sites use to change basic HTML into the layout and colours you want.   (Again it would be unusual to download such a file)
    If you want to know what created or might open a file search here (Common File Extensions)
    I would be cautious about deleting anything that you don't know what it is.
    The exception to that would be anything that is in your Downloads Folder or has been placed on the Desktop.
    Anything that is in Your Home Folder (the Little House icon) is yours.
    However deleting stuff in the Library that is inside there may cause problems with apps running properly.
    In may cases the Preferences you set are stored there. In some cases the results of you choices cause other things to be stored that are needed when the app runs.
    Deleting things in Documents, Pictures, Movies only deletes things you might want to Keep.
    I would also leave iTunes and iPhoto files alone in their relevant places.
    If in doubt post and ask.  Be clear about where the file is located and what you know about  how it got there.
    10:50 PM      Saturday; May 21, 2011
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.7)
     Mac OS X (10.6.7),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • I have a Mac Air. It said my start up disk was almost full and to delete files. I did but am not sure of what all I should delete. Then the color wheel wouldn't stop spinning so I just closed it. Now it won't open up at all. What can I do?

    I deleted files from my MacBook Air after it said my start up disk was almost full. It did several xs, then the color wheel wouldn't stop spinning, so I closed it. Then after a sufficient amount of time, I tried to start it up again, only now the Apple start up wheel just spins non stop and nothing else happens. How or what can I do to get my MacBook Air to work again, without having to take it in? Thanks so much!

    Backup your MBA then take it to Apple

  • Deleted files on external hard drive...but space isn't opening up!

    Hi all,
    I do my Time Machine backups to an external hd. I recently tried to do a backup and it failed, telling me there was not enough space. It told me I needed 12.something GB and I only had 10.something GB available.
    I checked the amount of available space on the hd, and sure enough there was about 10GB available. I deleted about 7GB of old music files (not backup files)--and when I checked available space again...it only showed the same 10GB! I deleted a little more...same thing. I was deleting files, but for some reason it wasn't creating any space on the hd.
    I thought I would just try to unplug it, restart computer, re-plug it in, and go ahead and try to do a backup with Time Machine. Well, again I got the message that the backup failed due to lack of space. Same numbers--12GB needed, only 10GB available.
    What the heck is going on? Why isn't deleting files creating more space on the hd? Any thoughts on this mystery? Thanks a lot!!!

    Are you emptying the Trash after deleting the files? You won't free any space until you do.
    No need to look for a Trash on the external; the normal Trash in the dock will do the job.

Maybe you are looking for

  • What's wrong with AdfPage.PAGE.findComonent?

    Hi, In this page I can't find the inputtext with the AdfPage.PAGE.findComonent and I don't know why, anybody see something wrong? If I try to find the component with document.getElementById works ok but I don't want to put ::content to find a compone

  • Best practice for install oracle 11g r2 on Windows Server 2008 r2

    Dear all, May I know what is the best practice for install oracle 11g r2 on windows server 2008 r2. Should I create a special account for windows for the oracle database installation? What permission should I grant to the folders where Oracle install

  • Quick VPN step-by-step guide!

    Hello. Can someone please provide a step-by-step guide on how to configure the SA-520 for Quick VPN Access? The manual doesn't describe this scenario at all, so please someone give me instructions how to set the IKE and VPN policy so that Quick VPN c

  • What is the definition of a Java Basic Block?

    The ClassFile specification reads "The intent is that a stack frame map must appear at the beginning of each basic block in a method." but it never goes about defining what a "basic block" is. http://en.wikipedia.org/wiki/Basic_block indicates that b

  • Ipod sync - iTunes versions

    I used iTunes 9.1.1 on a MacBook to synchronize my iPad. Then I transferred sync to iMac where iTunes 9.2 is installed. Does not work - it ill not update podcasts or photos. When I hook the iPad back on the old version of iTunes it works fine(!) Any