Process can't access file bcos another process has locked a portion of file

Does anyone knows if Java could handle the well-known "Open File" problem.
I encounter the following error when I was trying to copy an outlook file to another location:
java.io.IOException: The process cannot access the file because another process has locked a portion of the file.
My codes is placed below for reference.
Note that I was only trying to open to open the file for reading the Inputstream. Please advise what I could do to avoid getting caught in exception while reading the bytes.
It will be good if Java could handle the Microsoft's "Open File" problem.
// my codes
public static void main(String[] args)
int BUFSIZE = 4096;
File theFile = new File("C:\\Documents and Settings\\" + myID +
"\\Local Settings\\Application Data\\" +
"Microsoft\\Outlook\\mail.pst");
long size = theFile.length();
try {
FileInputStream fis = new FileInputStream(theFile);
// exception will happen on the next line
if (!(size >= 0 &&
fis.read(new byte[BUFSIZE],0,(int)Math.min(size,BUFSIZE)) > -1)) {
System.out.println("encountered OFM problem");
} else {
System.out.println("read file successfully");
} catch (Exception e) {
System.out.println("caught OFM problem");
e.printStackTrace();

Sometimes Windows can place a lock on files that will
prevent you from even reading its contents. You may
have to close the MS Outlook application in your
machine to be able to read the contents of this file.Of course I knew Microsoft has locked the file.
I also knows Microsoft locks a lot of other files too.
The idea is that we just want to read the file, we are not writing or modifying anyway, so we should be able to read it. Of course that depends on whether Java wants to step into the area and do something about it. (Please read http://www.stbernard.com/products/docs/ofm_whitepaperV8.pdf)
Well, the easiest way anyone could advise is probably to use Microsoft development tools. The idea is nobody wants to be a "Micro-slaves" if we could...
So I am still waiting for someone with the area of expertise to reply...

Similar Messages

  • Server 2012 R2 Backup to NAS fails: another process has locked portion of the file

    I am trying to setup Windows Server Backups in Server 2012R2
     My
    script didn't work, so started troubleshooting from the very bottom. My backup target is a DLink NAS drive with shared folder (full anonymous access and also tried setting up a dedicated user) Source to back up is a small folder on drive C From Server Backup
    manager -> Backup Once, add my folder to items to backup, point to \10.1.1.49\Volumes_1 Click backup, goes trough initial motion and the fails with error: "The process cannot access the file because another process has locked a portion of the file"

    Hi,
    Sorry for the delay in reply.
    Whether it is the same error message as before when trying to backup a newly created TXT file to the NAS?
    The message shows it is locked by a process so is there any security application running on your system? Test to disable them and see the result.
    As I'm not familiar with your NAS, you may need to confirm with its support to see if any change it will lock the backup process. 
    If you have any feedback on our support, please send to [email protected]

  • After trying to change permissions on my computer so others on my network can access files, my external Hard Drive has a lock on it and I can't access files. I've tried repairing permissions, logging in under another Administrator account, using Terminal

    After trying to change permissions on my computer so others on my network can grab files, my external Hard Drive has a lock on it and I can't access files. I've tried repairing permissions, logging in under another Administrator account, using Terminal to fix the problem, downloaded BatChmod but nothing works… Any other suggestions? I have an Imac running OS10.6.8.

    There is suddenly a lock icon on my external backup drive!
    Custom Permissions

  • How can I access files from a flash drive that were previously saved using a Windows computer? When I attempt to open the file on MacBook Pro, it is asking to "convert file to"; I also have Microsoft Word installed on the Mac as well.

    How can I access files from a flash drive that were previously saved using a Windows computer? When I attempt to open the file on MacBook Pro, it is asking to "convert file to"; none of the options I choose work. I also have Microsoft Office (with Word) installed on the Mac as well.

    Format the external drive as FAT32 or ExFAT. Both computers will then be able to read and write to it.

  • How can I access files that I moved from an older MacBook Pro to a newer one via Firewire and Migration assistant.  The files show up on the new MacBook but cannot be opened.  Thanks!

    How can I access files that I moved from an older MacBook Pro to a newer one via Firewire and Migration assistant?  The files show up on the new MacBook but cannot be opened.  Thanks!

    Get info then check permissions then add your curent user name (it was probably different on old Mac) and give your username full read/write permissions.

  • Can I access files copied to this machine in target disk mode from this machine?

    Can I access files copied to this machine in target disk mode from this machine?

    HI Claire,
    YOu didn't indicate which Mac OS you are using so I'm going to assume 10.4.x.
    Connect the FireWire cable to the target computer after starting it up in FireWire Target Disk Mode.
    *If the cable was already connected, unplugging it from either computer and plugging it back in should allow the target computer's hard disk to appear on the host.*
    Also, make sure you have the most recent Firmware for your iBook... go here:
    http://support.apple.com/kb/HT1471?viewlocale=en_US
    Carolyn

  • How to reset password on an ipad. I can't access the settings the iPad is locked

    How to reset password on an ipad. I can't access the settings the iPad is locked.

    If you are talking about the restrictions Passcode - there is no way to reset it. You have to restore the decide to factory settings. If you restore from a backup, and the Passcode is in the backup, that will not work since you will be restoring the Passcode that you cannot remember back onto the device.
    The only thing that would work is if your backup was created before you put the Passcode on the iPad. The Passcode would not be in that backup and you could restore from that one.

  • Mail says another app has locked it and won't go online.

    Mail (5.2) stays offline. I get a message saying that another application has locked mail.

    You have two devices that access the same email account with POP configuration, this lock the access from another device.
    the solution is to configure one device in IMAP,
    IMAP DON't lock the email account

  • Can't access files from one account to another on same Mac

    I've got a new macbook and I've divided it into two accounts. One account has all my iTunes music but the other is a fresh iTunes with no music.
    I've been trying to get access to the music from the other account. It seems like it should be easy as it's already on this computer. I've tried copying the iTunes folder into the public folder and going to the other account and copying it to it but that's not working.
    I've also tried sharing the files from the Sharing sys prefs. But can't get that to work. And I've also put the Music folder into the Shared folder and still nothing.
    The folders I need have the red minus on them.
    I must be missing something simple. Help!
    Thanks.

    wireduck,
    Highlight the music folder and on the keyboard type (Command) + i: on the window that opens scroll down if need and click on the lock on the bottom right. Type in an Admin User name and password. Then under the (Sharing & Permissions:) make sure the users you want to open the folder are listed and that there (Privilege) is set to @ least Read. If not hit the ( + ) sign and add them. After you have that all set up click on the little gear next to the ( - )s sign and (Apply to a enclosed items). that way each user can read the files. After that the little ( - ) sign should be gone on the folders.
    Hope that helps.

  • External Drive not showing up in Finder? Can't access files?

    My blue 1TB external WD Passport Drive (whose name is Ralph and who holds all kinds of precious things that I love and can't lose) isn't showing up on my Finder screen. Whenever I connect him, his light turns up and blinks as usual, but I can't access anything on him. I don't even get an error message when I disconnect him without ejecting. I've tried using different USB ports and different cables, but it's not helping. I've also tried connecting him to different computers (3 different macs and 1 Windows 8 PC), but NOTHING.
    I've been trying everything the past few days to get him to work. He shows up on Disk Utility occasionally. I've tried verifying and repairing him through Disk Utility, but it says that the verification could not be completed, or that it can't repair him. It tells me to back up as many files as I can and then restore him, but I can't access the files to back them up in the first place. Also, the partition name seems to have changed to 'disk1s3', which appears greyed out on the Disk Utility screen.
    In regards to mount point, it says that the disk isn't mounted. I tried mounting it by right-clicking it on Disk Utility, but the mount failed.
    I tried restoring him onto another 1TB WD drive (Oscar), but that failed too.
    How can we help Ralph? I don't believe in much, but I believe in Ralph.
    And that's why we have to help him.

    You can call Western Digital, but most likely they will give you the advice they gave another user recently to send it to Drive Savers for  data recovery. Drive Savesrs quoted him a price of $999 to just recover his photos from the drive.
    There is software you can try. Both have demos.
    FileSalvage $90
    Data Rescue $99
    DiskWarrior might be another option you can try. There is no demo. $99.99 http://www.alsoft.com/diskwarrior/
    Drive Savers
    http://hard-drive-recovery-services-review.toptenreviews.com/drive-savers-review .html
    In the future, you need to backup your important data to another external drive just for situations like this. Another option is to use a service like DropBox to upload files. This is mirrored on your drive so it's not always the best option.

  • Switching to Mac from WinXP - Can't access files of PC's secondary user

    This part works:
    To move files by connecting your Mac to your PC on the same network:
    Make sure that both computers are turned on and connected to the Internet.
    In the Finder on your Mac, choose Connect to Server from the Go menu to open the window.
    Type your PC's network address in the Server Address text box using this format: smb://ServerName/ShareName, or select the name of your PC in this window (if it appears).
    Click Connect.
    Enter your PC's workgroup name, your user name, and your password when prompted, then select the volume or folder you wish to access.
    Your PC volume should appear on your Mac Desktop.
    Open the volume and drag and drop files directly from it to anywhere on your Mac.
    But, once I get here, there are certain files I can't see. I want to start by migrating my photos. They reside in a subfolder of my wife's documents. She is a secondary user. As far as i can tell, i have all the sharing rights granted. Please help.
    MacBook Pro   Mac OS X (10.4.8)   PC has winxp sp2 with 2 users

    You will need to log into your wife's account in order to access any files stored in her user account. You can then move them to the /Users/Shared/ folder where you can then access them from your account.
    Why reward points?(Quoted from Discussions Terms of Use.)
    The reward system helps to increase community participation. When a community member gives you (or another member) a reward for providing helpful advice or a solution to their question, your accumulated points will increase your status level within the community.
    Members may reward you with 5 points if they deem that your reply is helpful and 10 points if you post a solution to their issue. Likewise, when you mark a reply as Helpful or Solved in your own created topic, you will be awarding the respondent with the same point values.

  • Why can I access files using ubuntu live cd but not my mac?

    Hello,
    Every since I have upgraded to Lion then to Mountain Lion I have had nothing but trouble with my mac crashing and not being able to repair the harddrive. I use time machine with an external hard drive to back up everything (also using online server to back up things as well).
    My issue is that disk utility never works ( ever ) and when I have trouble the hard drive and my external hard drive always show up grayed out and disk utility says the disk is broken and cannot be repaired. Which the disk are fine because I can access them using a ubuntu live cd no problem.
    My main question is how is this not being addressed by apple? This is clearly a bug - there is nothing wrong with my external harddrive or my macs hardrive - yet when I restart my mac I fear it will never start again(in its current state) and the disk utility just doesn't work the only answers I ever get is the hard drive is bad (which is not the case being I can access it with the ubuntu - or even reinstall everything and it works fine etc...)
    There is some major bugs and I can say I never had these problems losing my data with a windows machine (though I am not a big windows fan). Apple why doesn't the disk utility work?
    Also why when I update my mac and the mac restarts itself does it not eject my external hardrive - also why if you don't eject the harddrive it ruins the data on the hard drive or at least makes it grayed out or corrupt in my mac - but I can copy the files in ubuntu and put them back then it works just fine? These are serious issues and I am really shocked that the mac community would stand for this kind of thing - I am not the only one with these issues I see thousands of others with the same issues so when are they going to be fixed?
    If what I am saying is unclear - just google mac hardrive cannot be repaired - and set the time for the last month you will see. Also to those who have these troubles simply use a ubuntu live cd - copy all your files to the home folder then place them back to where the reside and mac will reconize them again - worked every time for me so far no thanks to disk utility.

    Your booting off a Ubuntu disk which has it's own operating system on it and on another medium that is free of issues, unlike your current hard drive running OS X 10.8.
    I really don't advise you directly installing Linux on a Mac as it's much more complicated that it appears. Also I don't advise you using Linux anything to tinker with a Mac unless you really really know what your doing.
    Since your Mac's software is broken you don't know currently and shouldn't be using Linux as a band-aid solution to your problem.
    My suggestion is you FIX your primary boot drive.
    disk utility says the disk is broken and cannot be repaired
    This calls for a complete zero erase and install of the affected area, if it's just the Macintosh HD partition then fine, it's a hold command r boot into Recovery HD and use Disk Utiltiy there to Erase with the middle secure erase feature (important) and then a reinstall of OS X 10.8 from Apple's servers over a fast Ethernet connection.
    If your GUID partition table or Recovery HD is affected, then you need to command option r boot into Internet Recovery and select the entire hard drive for the same zero/middle erase proceedure, unless you have a older MacBook Pro then you need to use option key boot off the 10.6 disks and use the Secure Erase/ Zero on the entire drive, install 10.6, then update to 10.6.8, then AppStore upgrade to 10.8 again.
    You need to only restore user files into same named accounts from a Storage Drive backup, do not use Migration or Setup assistant as your TimeMachine drive data is likely corrupted. This means all new softwre installs from original sources as well.
    Read through my many User Tips, you'll be fixing your own machine in no time.
    https://discussions.apple.com/community/notebooks/macbook_pro?view=documents#/?p er_page=50
    also why if you don't eject the harddrive it ruins the data on the hard drive or at least makes it grayed out or corrupt in my mac
    Windows and Linux also has to "safely remove hardware" or "unmount" before ejecting a drive as well or it corrupts the data.
    I guess this feature came about so one can disconnect a drive without having to physically remove it and wear out the ports doing so.

  • Time Machine: Can I access files from a PC that are on my external drive?

    If my iMac were to crash or die, I cannot afford to get it fixed or buy a new iMac, and the only computer I can then use is a PC, could I connect it to the external hard drive Time Machine had backed up to and access files, photos and music? Thank you in advance for your feedback.

    Ok, thanks. Yikes, that is extremely limiting. I guess I need to buy a separate external hard drive to backup important stuff in a way accessible from other computers like a PC. What about accessing files and photos from the current Time Machine hard drive from another Mac, say a friends, where I am not restoring everything to the Mac?

  • Can i access files from my iMac on my iPad

    I am a iMac user.  All my files (spreadsheets, documents, pics, music) are on the iMac.  I am moving to another state for the winter and l'm thinking about getting an iPad to use while Im gone.  Can I access my iMac files from my iPad?  What do I need to do to be able to have access to these files from the iPad?  Is there "an app for that"?

    Accessing the file system of a remote computer is not a native capability of the iPad, but there are third-party apps that can allow this to some extent. The one I see most often discussed is FileBrowser:
    http://www.stratospherix.com/products/filebrowser/
    Success with such apps will of course be dependent on getting any firewall on your iMac's network correctly set to allow access from outside the network, and of the iMac being on and awake. If either of those would be problematical, you might want to consider using a cloud-based storage solution such as Dropbox. That would probably not be practical if you want access to all your content, but a mixed solution, using Dropbox for normal files and iCloud for music, movies and photos, might work.
    Regards.

  • How can I access files that are saved in the iCloud?

    Hello fellow apple fans,
    I downloaded Mountain Lion yesterday and was very pleased to find out that it is possible to upload several file types from several programms into the iCloud. But now I am concerned that this feature could turn out to be useless for me: e.g. the PDF-upload from Preview" - once I uploaded it I can't find it annywhere, neither on my iPhone nor on icloud.com. I can only access it when I open Preview and look for "documents saved in the cloud". Same problem with several types of files - I can't find anything that can't be opend by the iWork-suit if I don't use the same programm that I used to save it in the cloud.
    Is this feature only meant to help people that own more than one Mac?
    Thanks for your help
    Thadeus1991

    Unfortunately, you're right. You can open iCloud documents on multiple devices, but only if they have the exact same software. If you save documents on Preview or TextEdit on your Mac, you can't open them on your iPad or iPhone because there is no equivalent software.
    I use Goodreader to read documents on my iPad and iPhone, and there is a workaround that I learned about on a popular Apple fan site that allows me to access my Goodreader iCloud files on my Mac (they are stored there even though there's no direct way to access them).  Hopefully, Apple will address this issue and make such workarounds unnecessary.

Maybe you are looking for

  • Satellite Pro U400-G13 - "C++ Runtime Error" on startup

    Hey Toshiba Forum Users I just bought a Satellite Pro U400-G13 I powered it up and the auto install startet Windows Vista. The computer restartet. After reboot a toshiba program starts up and requested a reboot more. After that I have a "C + + Runtim

  • Scrollbars In JTextArea

    Please see the link below for visual guide. http://pollscanada.com/screenshot.html I have my TextArea in the middle of the application which displays film titles when the user clicks on a category in the JComboBox further down on the left where it ha

  • HistoryManagerImpl throws a NullPointer

    hi, I am working with multiple InDesign extensions and trying to debug them. I open one extension, work with it, close InDesign. I try to debug my extension2 now. InDesign remembers the previous state and opens extension 1 for me. So far, so good. Bu

  • 2gb pf RAM the limit?

    i recently ugraded my ram from 1.5gb to 2. i did this buy buying a single 2gb RAM chip. now the issue is that if i put one of the other ram chips in with the 2gb (so i will have 2gb+) the imac will simply not boot. i was under the impression that a i

  • To remove Error in a Legacy Correction;  "Contains Errors In Process"

    Hi expert, I was trying to perform some action in my Legacy Correction and found out I have no authorization. Thus, a error came out, having the error message, red light, I quit the correction and came in again, it's still there, with System status "