Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

properties.store() fails occassionally

Posted on 2006-06-05
7
Medium Priority
?
237 Views
Last Modified: 2010-05-18
Hi All,

I am not sure why, on some m/cs properties.store() fail to update and store the file. The same code works only on some m/cs. All are windows os. The file is not read-only and there is no other application using it. Only String values are used for keys and values. Any input on occassions where the store() might fail would be greatly appreciated


Thanks
0
Comment
Question by:dasvinay
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 16833818
Make sure that the properties-file has not been opened by the same application elsewhere (ensure that you close all streams in finally blocks).
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 2000 total points
ID: 16833830
e.g.,

Properties p = new Properties () ;
FileInputStream fis = null ;
try
{
  fis = new FileInputStream ( "...." ) ;
  p.load ( fis ) ;
}
catch ( Exception e )
{
}
finally
{
  if ( fis != null )
    fis.close () ;
}

Handle exceptions as you want.

Also make sure that read/ write access to the properties-file is preferably synchronized.
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 16833853
> properties.store() fail to update and store the file
what Error/Exception do you get ?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dasvinay
ID: 16833867
Thanks for the quick reponse !

Yes, No other application or a service or any instance of the same application are open. The system is rebooted. This is the first action taken ie to update the properties file and it fails..


Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16833882
Do you close the InputStream?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16833887
Sorry - didn't see those replies when i posted
0
 

Author Comment

by:dasvinay
ID: 16833913
Good idea, I will synchronize the read/write. this might help.

Thanks everyone

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question