This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 1393
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: 19654
    
  18

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: 1393
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: 19654
    
  18

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
properties file
Using a Configuration Setting
Created File cannot be Deleted
Strange File Behavior
File Process Fails but Generated No Exception