From de1642bdb74c54168ca4b9d1f76249a6748dc058 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Thu, 10 May 2007 22:23:57 +0000 Subject: [PATCH] fix (I think) encoding for InputStream from StringResource git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@537018 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/types/resources/StringResource.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/org/apache/tools/ant/types/resources/StringResource.java b/src/main/org/apache/tools/ant/types/resources/StringResource.java index 30ec7d9a7..dc8e21bd9 100644 --- a/src/main/org/apache/tools/ant/types/resources/StringResource.java +++ b/src/main/org/apache/tools/ant/types/resources/StringResource.java @@ -15,7 +15,6 @@ * limitations under the License. * */ - package org.apache.tools.ant.types.resources; import java.io.IOException; @@ -183,11 +182,12 @@ public class StringResource extends Resource { if (isReference()) { return ((Resource) getCheckedRef()).getInputStream(); } - //I can't get my head around this; is encoding treatment needed here? - return - //new oata.util.ReaderInputStream(new InputStreamReader( - new ByteArrayInputStream(getContent().getBytes()); - //, encoding), encoding); + String content = getContent(); + if (content == null) { + throw new IllegalStateException("unset string value"); + } + return new ByteArrayInputStream(encoding == null + ? content.getBytes() : content.getBytes(encoding)); } /**