Browse Source

bit of cleanup here

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277861 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 20 years ago
parent
commit
4f0b53c73c
1 changed files with 8 additions and 15 deletions
  1. +8
    -15
      src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java

+ 8
- 15
src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2004 The Apache Software Foundation
* Copyright 2002-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.PropertySet; import org.apache.tools.ant.types.PropertySet;
import org.apache.tools.ant.util.CollectionUtils; import org.apache.tools.ant.util.CollectionUtils;
import org.apache.tools.ant.util.DOMElementWriter; import org.apache.tools.ant.util.DOMElementWriter;
import org.apache.tools.ant.util.FileUtils;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;


@@ -208,7 +209,7 @@ public class EchoProperties extends Task {
use Ant's properties */ use Ant's properties */
if (inFile == null && propertySets.size() == 0) { if (inFile == null && propertySets.size() == 0) {
// add ant properties // add ant properties
CollectionUtils.putAll(allProps, getProject().getProperties());
allProps.putAll(getProject().getProperties());
} else if (inFile != null) { } else if (inFile != null) {
if (inFile.exists() && inFile.isDirectory()) { if (inFile.exists() && inFile.isDirectory()) {
String message = "srcfile is a directory!"; String message = "srcfile is a directory!";
@@ -235,7 +236,7 @@ public class EchoProperties extends Task {
in = new FileInputStream(inFile); in = new FileInputStream(inFile);
Properties props = new Properties(); Properties props = new Properties();
props.load(in); props.load(in);
CollectionUtils.putAll(allProps, props);
allProps.putAll(props);
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
String message = String message =
"Could not find file " + inFile.getAbsolutePath(); "Could not find file " + inFile.getAbsolutePath();
@@ -255,20 +256,14 @@ public class EchoProperties extends Task {
} }
return; return;
} finally { } finally {
try {
if (null != in) {
in.close();
}
} catch (IOException ioe) {
//ignore
}
FileUtils.close(in);
} }
} }


Enumeration e = propertySets.elements(); Enumeration e = propertySets.elements();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
PropertySet ps = (PropertySet) e.nextElement(); PropertySet ps = (PropertySet) e.nextElement();
CollectionUtils.putAll(allProps, ps.getProperties());
allProps.putAll(ps.getProperties());
} }


OutputStream os = null; OutputStream os = null;
@@ -353,7 +348,7 @@ public class EchoProperties extends Task {
public String key; public String key;
public String value; public String value;


public Tuple(String key, String value) {
private Tuple(String key, String value) {
this.key = key; this.key = key;
this.value = value; this.value = value;
} }
@@ -412,9 +407,7 @@ public class EchoProperties extends Task {
} catch (IOException ioe) { } catch (IOException ioe) {
throw new BuildException("Unable to write XML file", ioe); throw new BuildException("Unable to write XML file", ioe);
} finally { } finally {
if (wri != null) {
wri.close();
}
FileUtils.close(wri);
} }
} }




Loading…
Cancel
Save