unload a properties file


hi there

i'm using this

Properties properties = new Properties();

properties.load (.......)

to load a properties file

Can someone tell me how i unload or close the properties file

many thanks
daleconAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
the load method closes it for you once read.
you don't need to do anything
0
CEHJCommented:
You don't. It's closed automatically
0
daleconAuthor Commented:


ok thanks
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

WebstormCommented:
>> Can someone tell me how i unload or close the properties file
If you mean unloading from memory, you can do :
    properties = new Properties();
old instance reference is lost and will be garbage-collected.
0
Mayank SAssociate Director - Product EngineeringCommented:
Or you can simply assign it to null:

properties = null ;
0
daleconAuthor Commented:


I'm seeing this in our tomcat logs, we were doing load testing, never seen this before

Properties exception java.io.FileNotFoundException: ... path to properties file ... (Too many open files)
WebappClassLoader: Failed to open JAR
0
objectsCommented:
Doubt it caused by Propoerties class, more likely to be elsewhere in your application.
0
CEHJCommented:
>>(Too many open files)

Don't think that means that a properties file got left open ;-) It could in fact mean that you've too many *sockets* open
0
WebstormCommented:
>> Properties exception java.io.FileNotFoundException: ... path to properties file ... (Too many open files)
There may be some InputStream/OutputStream you haven't closed in your application.

You should use streams like that:

     FileInputStream fis=new FileInputStream(" ... "); // or other opening of stream
     try{
          ... read/write
     } finally {  fis.close(); }
0
daleconAuthor Commented:


i do this

Properties properties = new Properties();

try
{
    properties.load(new FileInputStream(new File("path to properties file")));
    .......
}
catch
.......
0
mrigankCommented:
try
{
    File f = new File("path to properties file");
    FileInputStream fis = new FileInputStream(f);
    properties.load(fis);
    .......
    fis.cose();
    f.close();
}
0
WebstormCommented:

File f = new File("path to properties file");
FileInputStream fis = new FileInputStream(f);
try
{
    properties.load(fis);
    .......
}finally{
    fis.close();
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
daleconAuthor Commented:


try
{
    File f = new File("path to properties file");
    FileInputStream fis = new FileInputStream(f);
    properties.load(fis);
    .......
    fis.cose();
    f.close();
}

yep that's what i've changed it to, hopefully now when we do our load testing it won't be my code throwing the errors :]
0
WebstormCommented:
try my suggestion
0
Mayank SAssociate Director - Product EngineeringCommented:
>> that's what i've changed it to

You should close in the finally blocks like Webstorm told you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.