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?

Similar Messages

  • 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?

  • When i open an mp3 file from a source other than apple, does itunes create it's own file and can I then delete the original mp3?

    when I open a music file from a source other than apple, does itunes create it's own file and can I then delete the original mp3?

    If you use iTunes' default settings then when you add a file to iTunes it places a copy of the file in the iTunes media folder and it leaves the original in place.  The exception is when you drag it to the Automatically Add To iTunes folder.
    It does not convert the file.  You can delete the original if you wish.

  • Cannot delete exe files - The action can't be completed because the file is open in Windows Explorer

    We have received 3 new computers with Windows 8.1. All of us 3 have the same problem: we cannot delete exe files with message "The action can't be completed because the file is open in Windows Explorer"
    For example, I download skypeinstall.exe on desktop, install the program correctly and then try to delete the file: file is in use by Windows Explorer, cannot be delete.
    We reboot computer, we are able to delete the file. But, if I restore the file from the recycle bin on the desktop, I cannot delete it again until I reboot the PC. I used ProcessExplorer to see what is locking it and I can see 5 instances of explorer.exe
    locking the file.
    I can always reproduce the same way:
    1-Reboot
    2-Delete exe file
    3-Restore file
    4-Delete stop working and 5 explorer.exe handle are locking it.
    I have tried the following so far after reading multiple threads:
    - De-activating Windows Search service
    - Activating User Experience service
    - Deleting from command prompt (no success)
    - In folder options: inactivate display icon on thumbnail and activate always display icons, never thumbnail
    - Changing folder view (contents, detail, small icons...)
    - Using Lock Hunter - not working until reboot
    None of these worked.
    We all have Windows 8.1 with Crucial SSD drive, could the problem be linked with the SSD drive incompatibility?
    Any help would be appreciated.

    Hi,
    Please try to make a clean boot for your system, then check if this problem resolved.
    Clean Boot: http://support.microsoft.com/kb/929135
    If problem persists, try to open Resource Monitor to check handle of Explorer.exe, if there any exception, end them for test.
    Roger Lu
    TechNet Community Support

  • Cannot delete a file or open it from desktop

    Sorry if this is a repeat question, but I have not been able to find a good solution. When I try to delete a specific .aif file from my desktop, I get the following message:
    The operation can’t be completed because an unexpected error occurred (error code -8072).
    When I click 'get info' to possibly edit the permissions on it so I can delete it, I am unable to edit anything in the info pane. Under the Sharing & Permissions tab, it reads "You have unknown access." When I try to open the .aif file in iTunes, I get the following message:
    The Application "iTunes" can't be opened.
    -108
    However, iTunes works perfectly for me for all other compatible filetypes. Any help would be greatly appreciated!
    Cheers,
    Jacob

    Restart with the Option key held down and run repair disk from the recovery partition.
    (72343)

  • I am having problems gettting my mail to work ... Mac telling me that my start up disk id full and to delete some files to free up space ... have done this but when i open mail from the dock it just brings up the colour wheel and nothing happening

    I am having problems gettting my mail to work ... Mac telling me that my start up disk id full and to delete some files to free up space ... have done this but when i open mail from the dock it just brings up the colour wheel and nothing happening ... it shows when you right click on the mail icon that " application not responding"

    If your hard drive is getting full, you need to free up, at least, 20 GBs of space on your iMac's hard drive.
    If your Mac is running a fairly recent version of OS X, here are some general guidelines.
    Follow some of my tips for cleaning out, deleting and archiving data from your Mac's internal hard drive.
    Have you emptied your iMac's Trash icon in the Dock?
    If you use iPhoto, iPhoto has its own trash that needs to be emptied, also.
    If you use Apple Mail app, Apple Mail also has its own trash area that needs to be emptied, too!
    Other things you can do to gain space.
    Delete any old or no longer needed emails and/or archive to disc, flash drives or external hard drive, older emails you want to save.
    Look through your Documents folder and delete any type of old useless type files like "Read Me" type files.
    Again, archive to disc, flash drives, ext. hard drives or delete any old documents you no longer use or immediately need.
    Download an app called OnyX for your version of OS X.
    When you install and launch it, let it run the automatic ans S.M,A.R.T. tests,  then go to the cleaning and maintenance tabs and run the tabs that have the ability to clean out all web browser cache files, web browser histories, system cache files, delete old error log files.
    Typically, iTunes and iPhoto libraries are the biggest users of HD space.
    move these files/data off of your internal drive to the external hard drive and deleted off of the internal hard drive.
    If you have any other large folders of personal data or projects, these should be archived or moved, also, to the optical discs, flash drives or external hard drive and then either archived to disc and/or deleted off your internal hard drive.
    Good Luck!

  • Had to start Firefox in safe mode cause it kept crashing after i deleted the file. Now Fire fox Crashes every time I open it and I have to put it in safe mode j

    Had to start Firefox in safe mode cause it kept crashing after i deleted the file. Now Fire fox Crashes every time I open it and I have to put it in safe mode just to use it, also it's not syncing with my iPad.

    If you use Norton software, try disabling your Norton extensions. As of last week, there were severe compatibility issues with Firefox 24.

  • How to delete a file when it is open ?

    Hi all,
    I want to delete a file even it is open, and that should be deleted with out exiting the program itself. By using deleteOnExit() method of File class it is possible, but it is not valid for all types of files, and it works if we exit the program only.
    I need a way to delete a file even it is opened, and we should not use deleteOnExit() method to achieve it.
    Help appreciated ...

    Not possible.

  • I want to open a domain.site2 file outside the default folder (User/Library/Application Support/iWeb) with iWeb11, but iWeb only opens the domain file in the default folder. If I delete the default domain file, iWeb wants to create a new site. Help please

    I want to open a domain.site2 file outside the default folder (User/Library/Application Support/iWeb) with iWeb11, but iWeb only opens the domain file in the default folder. If I delete the default domain file, iWeb wants to create a new site. Does anyone have the same problem or know how to fix it?

    In Lion the Finder folder is now invisible.  To make it permanetely visible enter the following in the Terminal applicaiton window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    For opening your domain file in Lion for the first time or to switch between multiple domain files  Cyclosaurus has provided us with the following script that you can make into an Applescript application with Script Editor. Open Script Editor, copy and paste the script below into Script Editor's window and save as an applicaiton.
    Just launch the applicaiton, find and select the domain file you want to open and it will open with iWeb. It modifies the iWeb preference file each time it's launched so one can switch between domain files.
    do shell script "/usr/bin/defaults write com.apple.iWeb iWebDefaultsDocumentPath -boolean no"delay 1
    tell application "iWeb" to activate
    OT

  • Deselecting images in camera raw before opening the rest is deleting the files from finder!

    Hi, as the title suggests, im having an issue with of our machines. There are 6 running camera raw and it is the only one to do this (version 6.6).
    Example situation:
    10 RAW files are dragged into photoshop,
    they open in camera raw.
    all are selected and a white balance taken from the 'grey card' image that has been shot specifically.
    the grey card image is then deselected (with backspace button or otherwise) because i don't need it to be opened in photoshop for further editing with the rest.
    the problem:
    after clicking 'open images' the deselected grey card image is dissapearing from my finder window. the delay in opening in photoshop means i can actually watch it go.
    this doesnt happen on any other of my machines in the studio and that action should simply tell camera raw that i dont want to open that particular image in photoshop.
    can anyone tell me why it is doing that??
    we're working off our server (as we normally do), so the files arent being sent to the trash. if raws are worked on from the dekstop, the same thing happens and they obviously go straight to the trash then
    why is camera raw deleting my files? are they recovereable? how do i stop it?
    any help would be great. its a fast working studio and the grey card shots are not something we can afford to be losing.
    thanks,
    dom.

    Sounds like you're working over a network.
    This is the boilerplate text often used in connection to saving to a network (please NOTE the part where it explains that normally, it does work, but that it is impossible to troubleshoot someone else's network remotely, and that's why it's not supported by Adobe):
    If you are opening files over a network or saving them to a network server, please cease and desist immediately in the event you are currently experiencing problems with one or more files. Working across a network is not supported.
    See: 
    http://kb2.adobe.com/cps/406/kb406793.html
      Copy the CLOSED file from your server to your local hard disk, work on it, save it again to your local hard disk, close it, and copy the closed file back to the server.
         Of course, the fact that Adobe does not support working across a network does not necessarily mean it won't work.   It should.
        Adobe's position is that there are too many variables in a network environment for them to guarantee that everything will work correctly in every network, especially given the fact that if something does not work properly, it's probably the network's fault, and Adobe has no way of troubleshooting your network.
      If you can't work locally, you are on your own, and if something happens, you're on your own. If you must work from a server, make sure your network administrator is a competent professional.
    When problems arise, a lot of valuable work can be lost.

  • I have an alias file that will not delete or drag and it will not open to original file. How do I get these off my Mac?

    I have an alias file that will not delete or drag and it will not open to original file. I have tried everything I know and they still wont delete. Can someone please help me?

    Check out KB Article:  http://support.apple.com/kb/ht1526 You can't empty the Trash or move a file to the Trash 

  • Memory is supposedly Full, deleted some files, and now I can't open Itunes.

    I have a Macbook Pro but I don't play any games, I've never downloaded movies, but I do download music approx. 16GB and pictures...though not sure how to see how much memory these take up. Recently I've had trouble because my computer keeps notifying me that there is no space on the startup disk...which I can't understand why because I don't really have many files or programs on my computer. I've been deleting old files or things I don't really use and now my Itunes won't open saying there's an error (13014). So I have several questions, what is the best way to make space on the "startup disk" whatever that means, and how can I fix the error that's preventing me from accessing itunes? I have a feeling that my pictures might be taking up a lot of the space, how do I know when a single picture is too large and how could I condense them? Also when the memory gets full, my Microsoft Word starts acting all funky, is it because of the full memory? Thanks for your time:)
    -Danny

    Just as a matter of info you have posted in the MacBook Pro (Late 2008 and 2009) > Using your MacBook Pro (Late 2008 and 2009) forums. Not that your issue matters matters so much where it's posted but in the future you would want to post where users have similar hardware as you do, MacBook Pro (Original)
    http://discussions.apple.com/category.jspa?categoryID=250
    In any case as F Shippey suggests you may have directory issues. If Disk Utility cannot repair the directory then you may need a stronger disk utility like DiskWarrior to rebuild the directory.

  • HT1526 I can't delete any files, can't empty the trash bin, can't open my iTunes. Safari isn't working properly either. I keep getting the error message -50 when i try to delete anything...HELP!

    I can't delete any files, can't empty the trash bin, can't open my iTunes. Safari isn't working properly either. I keep getting the error message -50 when i try to delete anything...HELP!

    Hello, not too helpful, but...
    enum {
      paramErr                      = -50,  /*error in user parameter list*/
    Usually means a bvad or unacceptable Charachter in a File or Folder name...
    http://support.apple.com/kb/TA20831
    Solving Trash Problems...
    http://thexlab.com/faqs/trash.html
    Open Console in Utilities & see if there are any clues or repeating messages when trying to open Safari or iTunes.

  • Firefox opens minimized, Win8, mouseover shows website, will not maximize, Deleted Firefox files, Download new, Clean installs 3x

    Firefox opens minimized, Will not maximize. Using Win8/64bit. Left click will open new tabs etc, but they are also minimized.
    Did reinstall, Uninstalled Firefox, reinstalled - Did not work. Uninstalled, Deleted Firefox files. Downloaded new, reinstalled 3 times.
    Did not work. Typing this using IE

    wrong post

  • Can't open new Lion Mail? - Try delete the file "Envelope index"!

    Problem: can't start Mail.app after installing Lion. Mail.app repeatedIy crash when you accept the database upgrade.
    Possible solution:
    In Finder use Go to Folder... and type "~/Library/Mail".
    Delete the index file "Envelope index".
    Start Mail and it should work nicely.
    If you fear to delete it, move it to the Desktop. Go to step 3. If Mail works, it's safe to delete the file.
    This simple solution is found on many comments in this forum.

    FIXED!  My case was just successfully closed with Apple and I am now able to see my mail in Lion.  It took 2 days for Apple to come up with the resolution, and I was told that there were other cases of a siimilar nature reported.
    Here's what fixed it for me.  The problem had something to do with smartmailboxes, which I use in my mail.
    Close the Mail app and confirm it is closed.
    Open a Finder window.  Hold down the Option key while clicking Go along the top menu bar in the Finder window and click on Library.
    Navigate to the mail library under your user name.  In one of the subfolders, you will find 1 or more files named smartmailboxes.plist.  There may be a file name similar to that with "backup" in the name, as well.
    Drag each of those files to your desktop and ensure they are no longer in your mail library folders.
    Restart Mail.  (Those .plist files will be re-built automagically.)
    This fixed my problem and I was then able to delete those plist files from my desktop.  It did take a little while for the .plist files to regenerate, though.
    Good luck with your fix.

Maybe you are looking for

  • IPhone 4S does not sync with iTunes windows

    Hello I recently upgraded to an iphone 4S from a iphone 3GS.  The new phone was restored with my 3GS settings, apps, etc. For some recent  Iam able to sync with my iphone 3GS and my iTunes library (cabled) and all songs are successfully sync'd.  I am

  • Omitting drop down lists if a certain drop choice is chosen

    I have 5 drop down lists that have data binding to populate a text field with number values (12-34-567-89012-34).  There is one choice in the first drop down list that will populate the entire numbered sequence.  If that drop down choice is chosen, I

  • Setting GUI Status on CL_SALV_TABLE

    Hi All, I'm calling CL_SALV_TABLE in a method in the popup mode: *    Set popup display   lo_alv->set_screen_popup( start_column = 10                                   end_column   = 200                                   start_line   = 5             

  • Apologize and OAS 4.0.8

    Hi, I have had problems with the previous messages and the browser. Sorry for five stupid messgaes. I wanted to Know wich are the user and password for www.olab.com to download OAS 4.0.8. Thanks Jose R. Daz null

  • Trying to confirm new account info getting cannot be processed try again later error

    I have just established a new account and when I log in the itunes store wants me to confirm my info.    I do that, but then keep getting the error message "your request cannot be processed right now, try again later"  from what I see this is a messa