import java.io.BufferedReader;
import java.io.Reader;
+import java.io.Writer;
import java.util.Collections;
import java.util.List;
/** The reader to read commands from. */
private final BufferedReader reader;
+ /** The writer to write the results to. */
+ private final Writer writer;
+
/**
* Creates a new command reader.
*
* The core being controlled
* @param reader
* The reader to read commands from
+ * @param writer
+ * The write to write results to
*/
- public CommandReader(Core core, Reader reader) {
+ public CommandReader(Core core, Reader reader, Writer writer) {
this.core = core;
this.reader = new BufferedReader(reader);
+ this.writer = writer;
}
//
Collections.sort(lastResult);
int counter = 0;
for (Result result : lastResult) {
- System.out.println(String.format("[%d] %s (%s) from %s (#%s) on %s", counter++, result.pack().name(), result.pack().size(), result.bot().name(), result.pack().id(), result.bot().network().name()));
+ writer.write(String.format("[%d] %s (%s) from %s (#%s) on %s\n", counter++, result.pack().name(), result.pack().size(), result.bot().name(), result.pack().id(), result.bot().network().name()));
}
- System.out.println("End of Search.");
+ writer.write("End of Search.\n");
}
lastLine = line;
+ writer.flush();
}
}