Package org.jf.util

Class TwoColumnOutput

java.lang.Object
org.jf.util.TwoColumnOutput

public final class TwoColumnOutput extends Object
Class that takes a combined output destination and provides two output writers, one of which ends up writing to the left column and one which goes on the right.
  • Field Details

    • out

      private final Writer out
      non-null; underlying writer for final output
    • leftWidth

      private final int leftWidth
      > 0; the left column width
    • rightWidth

      private final int rightWidth
    • spacer

      private final String spacer
    • leftLines

      private String[] leftLines
    • rightLines

      private String[] rightLines
  • Constructor Details

    • TwoColumnOutput

      public TwoColumnOutput(@Nonnull Writer out, int leftWidth, int rightWidth, @Nonnull String spacer)
      Constructs an instance.
      Parameters:
      out - non-null; writer to send final output to
      leftWidth - > 0; width of the left column, in characters
      rightWidth - > 0; width of the right column, in characters
      spacer - non-null; spacer string to sit between the two columns
    • TwoColumnOutput

      public TwoColumnOutput(OutputStream out, int leftWidth, int rightWidth, String spacer)
      Constructs an instance.
      Parameters:
      out - non-null; stream to send final output to
      leftWidth - >= 1; width of the left column, in characters
      rightWidth - >= 1; width of the right column, in characters
      spacer - non-null; spacer string to sit between the two columns
  • Method Details

    • write

      public void write(String left, String right) throws IOException
      Throws:
      IOException
    • writeSpaces

      private static void writeSpaces(Writer out, int amt) throws IOException
      Writes the given number of spaces to the given writer.
      Parameters:
      out - non-null; where to write
      amt - >= 0; the number of spaces to write
      Throws:
      IOException