This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Becomes Locked so App Cannot Make Changes to it  RSS feed

 
Ranch Hand
Posts: 1826
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
Sheriff
Posts: 21288
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Steve Dyke
Ranch Hand
Posts: 1826
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 21288
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!