diff --git a/src/main/org/apache/tools/ant/filters/ClassConstants.java b/src/main/org/apache/tools/ant/filters/ClassConstants.java index 0bf76497d..01085d9b4 100644 --- a/src/main/org/apache/tools/ant/filters/ClassConstants.java +++ b/src/main/org/apache/tools/ant/filters/ClassConstants.java @@ -22,7 +22,7 @@ import java.io.Reader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.apache.tools.ant.BuildException; - +import org.apache.tools.ant.util.ResourceUtils; /** * Assembles the constants declared in a Java class in @@ -104,7 +104,7 @@ public final class ClassConstants if (clazz == null || clazz.length() == 0) { ch = -1; } else { - final byte[] bytes = clazz.getBytes("ISO-8859-1"); + final byte[] bytes = clazz.getBytes(ResourceUtils.ISO_8859_1); try { final Class javaClassHelper = Class.forName(JAVA_CLASS_HELPER); diff --git a/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java b/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java index 4357c42dc..044cc0f87 100644 --- a/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java +++ b/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java @@ -37,6 +37,7 @@ import org.apache.tools.ant.types.FilterChain; import org.apache.tools.ant.types.resources.FileResource; import org.apache.tools.ant.types.resources.JavaResource; import org.apache.tools.ant.util.FileUtils; +import org.apache.tools.ant.util.ResourceUtils; /** * Load a file's contents as Ant properties. @@ -181,7 +182,7 @@ public class LoadProperties extends Task { if (!text.endsWith("\n")) { text = text + "\n"; } - tis = new ByteArrayInputStream(text.getBytes("ISO8859_1")); + tis = new ByteArrayInputStream(text.getBytes(ResourceUtils.ISO_8859_1)); final Properties props = new Properties(); props.load(tis); diff --git a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java index 4b4f08854..88ce7f532 100644 --- a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java +++ b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java @@ -140,7 +140,7 @@ public class LayoutPreservingProperties extends Properties { public void load(InputStream inStream) throws IOException { String s = readLines(inStream); - byte[] ba = s.getBytes("ISO-8859-1"); + byte[] ba = s.getBytes(ResourceUtils.ISO_8859_1); ByteArrayInputStream bais = new ByteArrayInputStream(ba); super.load(bais); } @@ -251,7 +251,7 @@ public class LayoutPreservingProperties extends Properties { } public void store(OutputStream out, String header) throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(out, "ISO-8859-1"); + OutputStreamWriter osw = new OutputStreamWriter(out, ResourceUtils.ISO_8859_1); int skipLines = 0; int totalLines = logicalLines.size(); @@ -309,7 +309,7 @@ public class LayoutPreservingProperties extends Properties { * @param is the stream from which to read the data */ private String readLines(InputStream is) throws IOException { - InputStreamReader isr = new InputStreamReader(is, "ISO-8859-1"); + InputStreamReader isr = new InputStreamReader(is, ResourceUtils.ISO_8859_1); BufferedReader br = new BufferedReader(isr); if (logicalLines.size() > 0) { diff --git a/src/main/org/apache/tools/ant/util/ResourceUtils.java b/src/main/org/apache/tools/ant/util/ResourceUtils.java index 7413914d0..9c1fb433e 100644 --- a/src/main/org/apache/tools/ant/util/ResourceUtils.java +++ b/src/main/org/apache/tools/ant/util/ResourceUtils.java @@ -65,6 +65,13 @@ public class ResourceUtils { /** Utilities used for file operations */ private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); + /** + * Name of charset "ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1". + * + * @since Ant 1.8.1 + */ + public static final String ISO_8859_1 = "ISO-8859-1"; + /** * Tells which source files should be reprocessed based on the * last modification date of target files.