maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r682914 - /maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/WebappStructureSerializer.java
Date Tue, 05 Aug 2008 20:03:53 GMT
Author: hboutemy
Date: Tue Aug  5 13:03:53 2008
New Revision: 682914

URL: http://svn.apache.org/viewvc?rev=682914&view=rev
Log:
fixed encoding used to read or write webapp structure XML file

Modified:
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/WebappStructureSerializer.java

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/WebappStructureSerializer.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/WebappStructureSerializer.java?rev=682914&r1=682913&r2=682914&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/WebappStructureSerializer.java
(original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/WebappStructureSerializer.java
Tue Aug  5 13:03:53 2008
@@ -21,11 +21,14 @@
 
 import com.thoughtworks.xstream.XStream;
 import org.apache.maven.model.Dependency;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.WriterFactory;
 
 import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
 import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
 
 /**
  * Serializes {@link WebappStructure} back and forth.
@@ -62,19 +65,16 @@
     public WebappStructure fromXml( File file )
         throws IOException
     {
-        FileReader reader = null;
+        Reader reader = null;
 
         try
         {
-            reader = new FileReader( file );
+            reader = ReaderFactory.newXmlReader( file );
             return (WebappStructure) xStream.fromXML( reader );
         }
         finally
         {
-            if ( reader != null )
-            {
-                reader.close();
-            }
+            IOUtil.close( reader );
         }
     }
 
@@ -88,7 +88,7 @@
     public void toXml( WebappStructure webappStructure, File targetFile )
         throws IOException
     {
-        FileWriter writer = null;
+        Writer writer = null;
         try
         {
             if ( !targetFile.getParentFile().exists() && !targetFile.getParentFile().mkdirs()
)
@@ -101,15 +101,12 @@
             {
                 throw new IOException( "Could not create file[" + targetFile.getAbsolutePath()
+ "]" );
             }
-            writer = new FileWriter( targetFile );
+            writer = WriterFactory.newXmlWriter( targetFile );
             xStream.toXML( webappStructure, writer );
         }
         finally
         {
-            if ( writer != null )
-            {
-                writer.close();
-            }
+            IOUtil.close( writer );
         }
     }
 }



Mime
View raw message