From 3c5f84b6b679737c9abc31aa11c02d42f6fdfa95 Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Thu, 17 Nov 2005 02:19:16 +0000 Subject: [PATCH] fix encoding issues in parser git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@345168 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/bootstrap/util/AbstractReader.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/util/AbstractReader.java b/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/util/AbstractReader.java index 2bc86d9633..f37fa79c90 100644 --- a/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/util/AbstractReader.java +++ b/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/util/AbstractReader.java @@ -24,11 +24,11 @@ import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileReader; +import java.io.FileInputStream; import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; /** * Parse an XML file. @@ -52,12 +52,12 @@ public abstract class AbstractReader SAXParser parser = saxFactory.newSAXParser(); // Cheap and cheerful. Please add more to skip if the parser chokes (or use the actual - StringWriter output = new StringWriter(); - IOUtil.copy( new FileReader( file ), output); - String out = output.toString(); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + IOUtil.copy( new FileInputStream( file ), output ); + String out = output.toString( "UTF-8" ); out = StringUtils.replace( out, "ø", "\u00f8" ); - InputSource is = new InputSource( new StringReader( out ) ); + InputSource is = new InputSource( new ByteArrayInputStream( out.getBytes( "UTF-8" ) ) ); try { @@ -87,7 +87,7 @@ public abstract class AbstractReader private final void printParseError( String type, SAXParseException spe ) { - System.err.println( type + " [line " + spe.getLineNumber() + ", row " + spe.getColumnNumber() + "]: " + - spe.getMessage() ); + System.err.println( + type + " [line " + spe.getLineNumber() + ", row " + spe.getColumnNumber() + "]: " + spe.getMessage() ); } }