From 6df6da151ec3804a8f3cc8ac65277842358d7e38 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 14 Apr 2013 14:35:55 +0200 Subject: [PATCH] Remove write() methods to prevent mulitple flush()s per line. --- .../pterodactylus/xdcc/ui/stdin/CommandReader.java | 23 +++++----------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java index 795fe98..a530a1d 100644 --- a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java +++ b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java @@ -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 -- 2.7.4