Selaa lähdekoodia

Fix changes to StreamReader/StreamUtils.

Depends-On: Ia24b29f2fcd414d7b27bad52cc6fad6312179de5
Change-Id: Ie4bd081e56c12afe66a0f333a36e7f87b1736048
Reviewed-on: http://gerrit.dmdirc.com/4068
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/68/4068/2
Greg Holmes 9 vuotta sitten
vanhempi
commit
0fe6bea009

+ 14
- 13
dcc/src/com/dmdirc/addons/dcc/kde/KDialogProcess.java Näytä tiedosto

@@ -22,11 +22,12 @@
22 22
 
23 23
 package com.dmdirc.addons.dcc.kde;
24 24
 
25
-import com.dmdirc.util.io.StreamReader;
25
+import com.dmdirc.util.io.StreamUtils;
26 26
 
27 27
 import java.io.File;
28 28
 import java.io.IOException;
29 29
 import java.util.ArrayList;
30
+import java.util.List;
30 31
 
31 32
 /**
32 33
  * Hold a Process and stream readers for a KDialog Process.
@@ -37,10 +38,10 @@ public class KDialogProcess {
37 38
     private static final boolean IS_BIN = new File("/bin/kdialog").exists();
38 39
     /** Does KDialog exist? */
39 40
     private static final boolean HAS_KDIALOG = IS_BIN || new File("/usr/bin/kdialog").exists();
40
-    /** Stream for the stdout stream for this process. */
41
-    private final StreamReader stdOutputStream;
42
-    /** Stream for the stderr stream for this process. */
43
-    private final StreamReader stdErrorStream;
41
+    /** Output from the output stream. */
42
+    private final List<String> stdOutput;
43
+    /** Output from the error stream. */
44
+    private final List<String> stdError;
44 45
     /** The actual process for this process. */
45 46
     private final Process process;
46 47
 
@@ -56,10 +57,10 @@ public class KDialogProcess {
56 57
         System.arraycopy(params, 0, exec, 1, params.length);
57 58
         exec[0] = IS_BIN ? "/bin/kdialog" : "/usr/bin/kdialog";
58 59
         process = Runtime.getRuntime().exec(exec);
59
-        stdOutputStream = new StreamReader(process.getInputStream(), new ArrayList<String>());
60
-        stdErrorStream = new StreamReader(process.getErrorStream(), new ArrayList<String>());
61
-        stdOutputStream.start();
62
-        stdErrorStream.start();
60
+        stdOutput = new ArrayList<>();
61
+        stdError = new ArrayList<>();
62
+        StreamUtils.readStreamIntoList(process.getInputStream(), stdOutput);
63
+        StreamUtils.readStreamIntoList(process.getErrorStream(), stdError);
63 64
     }
64 65
 
65 66
     /**
@@ -85,8 +86,8 @@ public class KDialogProcess {
85 86
      *
86 87
      * @return The StreamReader for this KDialogProcess's stdout stream
87 88
      */
88
-    public StreamReader getStdOutStream() {
89
-        return stdOutputStream;
89
+    public List<String> getStdOut() {
90
+        return stdOutput;
90 91
     }
91 92
 
92 93
     /**
@@ -94,8 +95,8 @@ public class KDialogProcess {
94 95
      *
95 96
      * @return The StreamReader for this KDialogProcess's stderr stream
96 97
      */
97
-    public StreamReader getStdErrStream() {
98
-        return stdErrorStream;
98
+    public List<String> getStdErr() {
99
+        return stdError;
99 100
     }
100 101
 
101 102
     /**

+ 3
- 3
dcc/src/com/dmdirc/addons/dcc/kde/KFileChooser.java Näytä tiedosto

@@ -198,14 +198,14 @@ public class KFileChooser extends JFileChooser {
198 198
 
199 199
         if (kdp.getProcess().exitValue() == 0) {
200 200
             if (isMultiSelectionEnabled()) {
201
-                final List<String> list = kdp.getStdOutStream().getList();
201
+                final List<String> list = kdp.getStdOut();
202 202
                 final File[] fileList = new File[list.size()];
203 203
                 for (int i = 0; i < list.size(); ++i) {
204 204
                     fileList[i] = new File(list.get(i));
205 205
                 }
206 206
                 setSelectedFiles(fileList);
207 207
             } else {
208
-                setSelectedFile(new File(kdp.getStdOutStream().getList().get(0)));
208
+                setSelectedFile(new File(kdp.getStdOut().get(0)));
209 209
             }
210 210
             return JFileChooser.APPROVE_OPTION;
211 211
         } else {
@@ -246,7 +246,7 @@ public class KFileChooser extends JFileChooser {
246 246
         }
247 247
 
248 248
         if (kdp.getProcess().exitValue() == 0) {
249
-            setSelectedFile(new File(kdp.getStdOutStream().getList().get(0)));
249
+            setSelectedFile(new File(kdp.getStdOut().get(0)));
250 250
             return JFileChooser.APPROVE_OPTION;
251 251
         } else {
252 252
             return JFileChooser.ERROR_OPTION;

+ 3
- 8
exec/src/com/dmdirc/addons/exec/ExecCommand.java Näytä tiedosto

@@ -33,7 +33,7 @@ import com.dmdirc.events.UserErrorEvent;
33 33
 import com.dmdirc.interfaces.CommandController;
34 34
 import com.dmdirc.logger.ErrorLevel;
35 35
 import com.dmdirc.util.CommandUtils;
36
-import com.dmdirc.util.io.StreamReader;
36
+import com.dmdirc.util.io.StreamUtils;
37 37
 
38 38
 import java.io.File;
39 39
 import java.io.IOException;
@@ -88,13 +88,8 @@ public class ExecCommand extends Command {
88 88
                         ? null : new LinkedList<String>();
89 89
                 final List<String> errorOutput = args.isSilent()
90 90
                         ? null : new LinkedList<String>();
91
-                final StreamReader inputReader = new StreamReader(
92
-                        p.getInputStream(), execOutput);
93
-                final StreamReader errorReader = new StreamReader(
94
-                        p.getErrorStream(), errorOutput);
95
-
96
-                inputReader.run();
97
-                errorReader.run();
91
+                StreamUtils.readStreamIntoList(p.getInputStream(), execOutput);
92
+                StreamUtils.readStreamIntoList(p.getErrorStream(), errorOutput);
98 93
                 if (!args.isSilent()) {
99 94
                     for (String line : execOutput) {
100 95
                         sendLine(origin, args.isSilent(), FORMAT_OUTPUT, line);

+ 3
- 3
freedesktop_notifications/src/com/dmdirc/addons/freedesktop_notifications/FDManager.java Näytä tiedosto

@@ -33,7 +33,7 @@ import com.dmdirc.logger.ErrorLevel;
33 33
 import com.dmdirc.plugins.PluginDomain;
34 34
 import com.dmdirc.plugins.implementations.PluginFilesHelper;
35 35
 import com.dmdirc.ui.messages.Styliser;
36
-import com.dmdirc.util.io.StreamReader;
36
+import com.dmdirc.util.io.StreamUtils;
37 37
 
38 38
 import com.google.common.base.Strings;
39 39
 import com.google.common.html.HtmlEscapers;
@@ -110,8 +110,8 @@ public class FDManager implements ConfigChangeListener {
110 110
         try {
111 111
             final Process myProcess = Runtime.getRuntime().exec(args);
112 112
             final StringBuffer data = new StringBuffer();
113
-            new StreamReader(myProcess.getErrorStream()).start();
114
-            new StreamReader(myProcess.getInputStream(), data).start();
113
+            StreamUtils.readStream(myProcess.getErrorStream());
114
+            StreamUtils.readStreamIntoStringBuffer(myProcess.getInputStream(), data);
115 115
             try {
116 116
                 myProcess.waitFor();
117 117
             } catch (InterruptedException e) {

+ 3
- 3
mediasource_windows/src/com/dmdirc/addons/mediasource_windows/WindowsMediaSourcePlugin.java Näytä tiedosto

@@ -27,7 +27,7 @@ import com.dmdirc.addons.nowplaying.MediaSourceManager;
27 27
 import com.dmdirc.plugins.PluginInfo;
28 28
 import com.dmdirc.plugins.implementations.BasePlugin;
29 29
 import com.dmdirc.plugins.implementations.PluginFilesHelper;
30
-import com.dmdirc.util.io.StreamReader;
30
+import com.dmdirc.util.io.StreamUtils;
31 31
 
32 32
 import java.io.IOException;
33 33
 import java.util.ArrayList;
@@ -76,8 +76,8 @@ public class WindowsMediaSourcePlugin extends BasePlugin
76 76
                 player,
77 77
                 method});
78 78
             final StringBuffer data = new StringBuffer();
79
-            new StreamReader(myProcess.getErrorStream()).start();
80
-            new StreamReader(myProcess.getInputStream(), data).start();
79
+            StreamUtils.readStream(myProcess.getErrorStream());
80
+            StreamUtils.readStreamIntoStringBuffer(myProcess.getInputStream(), data);
81 81
             try {
82 82
                 myProcess.waitFor();
83 83
             } catch (InterruptedException e) {

Loading…
Peruuta
Tallenna