Fix problem with the JpredWS service. Now Jws2Client is able to test the service
[jabaws.git] / webservices / compbio / ws / client / AAConClient.java
index 4619c60..f7f2603 100644 (file)
@@ -1,6 +1,6 @@
-/* Copyright (c) 2010 Peter Troshin\r
+/* Copyright (c) 2011 Peter Troshin\r
  *  \r
- *  Amino Acid Conservation Web Service client @version: 1.0     \r
+ *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
  * \r
  *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
  *  Apache License version 2 as published by the Apache Software Foundation\r
@@ -30,7 +30,8 @@ import static compbio.ws.client.Constraints.pseparator;
 import java.io.Closeable;\r
 import java.io.File;\r
 import java.io.IOException;\r
-import java.io.OutputStream;\r
+import java.io.PrintWriter;\r
+import java.io.Writer;\r
 import java.net.MalformedURLException;\r
 import java.net.URL;\r
 import java.util.List;\r
@@ -116,13 +117,13 @@ public class AAConClient {
                if (inputFile != null) {\r
                        System.out.println("Calculating conservation...");\r
                        result = analize(inputFile, msaws, preset, customOptions);\r
-                       OutputStream outStream = null;\r
+                       Writer outStream = null;\r
                        if (outFile != null) {\r
-                               outStream = IOHelper.getOutStream(outFile);\r
+                               outStream = IOHelper.getWriter(outFile);\r
                        } else {\r
                                // this stream is going to be closed later which is fine as\r
                                // std.out will not be\r
-                               outStream = System.out;\r
+                               outStream = new PrintWriter(System.out, true);\r
                        }\r
                        writeOut(outStream, result);\r
                        // stream is closed in the method no need to close it here\r
@@ -152,17 +153,17 @@ public class AAConClient {
         * @param result\r
         *            the AACon scores to output\r
         */\r
-       static void writeOut(OutputStream outStream, ScoreManager result) {\r
+       static void writeOut(Writer writer, ScoreManager result) {\r
                try {\r
-                       result.writeOut(outStream);\r
+                       result.writeOut(writer);\r
                } catch (IOException e) {\r
                        System.err\r
                                        .println("Problems writing output file! Stack trace is below: ");\r
                        e.printStackTrace();\r
                } finally {\r
-                       if (outStream != null) {\r
+                       if (writer != null) {\r
                                try {\r
-                                       outStream.close();\r
+                                       writer.close();\r
                                } catch (IOException ignored) {\r
                                        // e.printStackTrace();\r
                                }\r