OSDN Git Service

fixed findbugs warnings.
[stigmata/stigmata.git] / src / main / java / jp / sourceforge / stigmata / command / ExportConfigCommand.java
index f572ad7..06dc1fd 100644 (file)
@@ -1,8 +1,9 @@
 package jp.sourceforge.stigmata.command;
 
-import java.io.FileWriter;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.OutputStreamWriter;
 
 import jp.sourceforge.stigmata.BirthmarkContext;
 import jp.sourceforge.stigmata.Stigmata;
@@ -23,14 +24,15 @@ public class ExportConfigCommand extends AbstractStigmataCommand{
     public boolean perform(Stigmata stigmata, BirthmarkContext context, String[] args){
         PrintWriter out = null;
         try{
+            String encoding = getProperty(context, new String[] { "encoding.output", "encoding", }, "utf-8");
             if(args == null || args.length == 0){
-                out = new PrintWriter(System.out);
+                out = new PrintWriter(new OutputStreamWriter(System.out, encoding));
             }
             else{
                 if(!args[0].endsWith(".xml")){
                     args[0] = args[0] + ".xml";
                 }
-                out = new PrintWriter(new FileWriter(args[0]));
+                out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(args[0]), encoding));
             }
 
             new ConfigFileExporter(context.getEnvironment()).export(out);