ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <pjdon...@cs.latrobe.edu.au>
Subject Re: <delete> unable to remove a file
Date Mon, 02 Oct 2000 09:42:55 GMT
At 09:31  2/10/00 +0200, you wrote:
>If it's not the propertyFile-task you may try to change 'loadFile' in
>Property.java as follows:
>
>    private void loadFile (File file) throws BuildException {
>        Properties props = new Properties();
>        log("Loading " + file.getAbsolutePath(), Project.MSG_VERBOSE);
>        try {
>            if (file.exists())
>
>                FileInputStream fis = new FileInputStream(file);
>                props.load(fis);
>                fis.close();
>                addProperties(props);
>            } else {
>                log("Unable to find " + file.getAbsolutePath(),
>                    Project.MSG_VERBOSE);
>            }
>        } catch(Exception ex) {
>            throw new BuildException(ex.getMessage(), ex, location);
>        }
>    }
>
>I'm not sure what Java is 'required to do' if you use something like
>'props.load(new FileInputStream(file));' - it can immediately close the file
>after loading, but will it do in all cases?

Nope and it is the source of much hell in developing on NT. You should
always explictly close all file handles or else NT will not be able to
delete them ;(


Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*

Mime
View raw message