db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r405519 - /db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java
Date Tue, 09 May 2006 20:00:44 GMT
Author: tomdz
Date: Tue May  9 13:00:43 2006
New Revision: 405519

URL: http://svn.apache.org/viewcvs?rev=405519&view=rev
Log:
Fixed possible bug with the encoding of file created by the dump metadata task

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java?rev=405519&r1=405518&r2=405519&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java Tue May  9 13:00:43
2006
@@ -17,7 +17,7 @@
  */
 
 import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.sql.Connection;
@@ -57,6 +57,8 @@
     private BasicDataSource _dataSource;
     /** The file to write the dump to. */
     private File _outputFile = null;
+    /** The encoding of the XML output file. */
+    private String _outputEncoding = "UTF-8";
     /** The database catalog(s) to read. */
     private String _catalogPattern = "%";
     /** The database schema(s) to read. */
@@ -95,6 +97,16 @@
     }
 
     /**
+     * Set the encoding of the output file.
+     *
+     * @param encoding The encoding
+     */
+    public void setOutputEncoding(String encoding)
+    {
+        _outputEncoding = encoding;
+    }
+
+    /**
      * Sets the catalog pattern.
      *
      * @param catalogPattern The catalog pattern
@@ -213,18 +225,20 @@
             
             dumpMetaData(root, connection.getMetaData());
 
-            XMLWriter writer = null;
+            OutputFormat outputFormat = OutputFormat.createPrettyPrint();
+            XMLWriter    xmlWriter    = null;
 
+            outputFormat.setEncoding(_outputEncoding);
             if (_outputFile == null)
             {
-                writer = new XMLWriter(System.out, OutputFormat.createPrettyPrint());
+                xmlWriter = new XMLWriter(System.out, outputFormat);
             }
             else
             {
-                writer = new XMLWriter(new FileWriter(_outputFile), OutputFormat.createPrettyPrint());
+                xmlWriter = new XMLWriter(new FileOutputStream(_outputFile), outputFormat);
             }
-            writer.write(document);
-            writer.close();
+            xmlWriter.write(document);
+            xmlWriter.close();
         }
         catch (Exception ex)
         {



Mime
View raw message