wood burning stoves 2.0*
The moose likes Java in General and the fly likes File Becomes Locked so App Cannot Make Changes to it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "File Becomes Locked so App Cannot Make Changes to it" Watch "File Becomes Locked so App Cannot Make Changes to it" New topic
Author

File Becomes Locked so App Cannot Make Changes to it

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1391
When I run the following the file becomes Locked and the App cannot manipulate it.
How can I release the file after the properties are retreived?

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Always close all your resources*. Use a finally block for this; don't be afraid to nest try statements:
* like InputStreams, OutputStreams, Readers, Writers, SQL connections, SQL statements, SQL result sets, etc.

You may see the following, but I think it's a lot nastier:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1391
Rob Prime wrote:Always close all your resources*. Use a finally block for this; don't be afraid to nest try statements:


Thanks, this is exactly what I needed.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Becomes Locked so App Cannot Make Changes to it
 
Similar Threads
File Process Fails but Generated No Exception
Created File cannot be Deleted
properties file
Using a Configuration Setting
Strange File Behavior