1 package edu.uci.iotproject.io;
3 import java.io.PrintWriter;
6 * Utility methods for (jointly) printing to a {@link PrintWriter} (and standard output).
8 * @author Janus Varmarken {@literal <jvarmark@uci.edu>}
9 * @author Rahmadi Trimananda {@literal <rtrimana@uci.edu>}
11 public final class PrintWriterUtils {
13 private PrintWriterUtils() {
14 // Disallow instantiation. Static-only class.
18 * Invoke {@link PrintWriter#println(Object)} passing {@code line} as argument while also printing {@code line} to
19 * standard output if {@code duplicateToStdOut} is {@code true}.
20 * @param line The line to be printed.
21 * @param writer The {@link PrintWriter} that is to print {@code line}.
22 * @param duplicateToStdOut Set to {@code true} if {@code line} should also be printed in standard output.
24 public static void println(Object line, PrintWriter writer, boolean duplicateToStdOut) {
25 if (duplicateToStdOut) {
26 System.out.println(line);
32 * Make writer (and standard output, if {@code duplicateToStdOut} is {@code true}) print an empty line.
33 * @param writer The writer that {@link PrintWriter#println()} is to be invoked on.
34 * @param duplicateToStdOut If {@code true}, prints an empty line to standard output.
36 public static void printEmptyLine(PrintWriter writer, boolean duplicateToStdOut) {
37 if (duplicateToStdOut) {