Remove write() methods to prevent mulitple flush()s per line.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 14 Apr 2013 12:35:55 +0000 (14:35 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 14 Apr 2013 12:35:55 +0000 (14:35 +0200)
src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java

index 795fe98..a530a1d 100644 (file)
@@ -119,17 +119,17 @@ public class CommandReader extends AbstractExecutionThreadService {
                        } else if (words[0].equalsIgnoreCase("dcc")) {
                                int counter = 0;
                                for (DccReceiver dccReceiver : core.dccReceivers()) {
-                                       write(String.format("[%d] %s (%s, ", counter++, dccReceiver.filename(), dccReceiver.size()));
+                                       writer.write(String.format("[%d] %s (%s, ", counter++, dccReceiver.filename(), f(dccReceiver.size())));
                                        if (dccReceiver.isRunning()) {
-                                               write(String.format("%.1f%%, %s", dccReceiver.progress() * 100.0 / dccReceiver.size(), f(dccReceiver.currentRate())));
+                                               writer.write(String.format("%.1f%%, %s", dccReceiver.progress() * 100.0 / dccReceiver.size(), f(dccReceiver.currentRate())));
                                        } else {
                                                if (dccReceiver.progress() >= dccReceiver.size()) {
-                                                       write(String.format("complete, %s", f(dccReceiver.overallRate())));
+                                                       writer.write(String.format("complete, %s", f(dccReceiver.overallRate())));
                                                } else {
-                                                       write(String.format("aborted at %.1f%%, %s", dccReceiver.progress() * 100.0 / dccReceiver.size(), f(dccReceiver.currentRate())));
+                                                       writer.write(String.format("aborted at %.1f%%, %s", dccReceiver.progress() * 100.0 / dccReceiver.size(), f(dccReceiver.currentRate())));
                                                }
                                        }
-                                       write("/s)\n");
+                                       writer.write("/s)\n");
                                }
                                writeLine("End of DCCs.");
                        } else if (words[0].equalsIgnoreCase("get")) {
@@ -245,19 +245,6 @@ public class CommandReader extends AbstractExecutionThreadService {
        //
 
        /**
-        * Writes the given text to the {@link #writer}.
-        *
-        * @param text
-        *              The text to write
-        * @throws IOException
-        *              if an I/O error occurs
-        */
-       private void write(String text) throws IOException {
-               writer.write(text);
-               writer.flush();
-       }
-
-       /**
         * Writes the given line followed by an LF to the {@link #writer}.
         *
         * @param line