### Question:
FixedWidthFormatter extends AbstractMultiLineFormatter { public void transform(StringBuilder buffer, StringBuilder remainder) { m_flow.flow(buffer, remainder, m_width); final int length = buffer.length(); for (int k = 0; k < length; k++) { if (Character.isWhitespace(buffer.charAt(k))) { buffer.setCharAt(k, ' '); } } if (length < m_width) { m_alignment.pad(buffer, m_width - length); } } FixedWidthFormatter(Align alignment, Flow flow, int width); void transform(StringBuilder buffer, StringBuilder remainder);  }### Answer:
@Test public void testTruncate() throws Exception { final String text = "They walked in a line, they wallked in a line"; final String text2 = "Be on my side and I'll be on your side"; for (int width=1; width<20; ++width) { final MultiLineFormatter leftFormatter = new FixedWidthFormatter(FixedWidthFormatter.Align.LEFT, FixedWidthFormatter.Flow.TRUNCATE, width); for (int i=0; i<text.length(); ++i) { final StringBuilder buffer = new StringBuilder(text.substring(0, i)); final StringBuilder remainder = new StringBuilder(text2); leftFormatter.transform(buffer, remainder); final String result = buffer.toString(); assertEquals(width, result.length()); if (i<width) { assertEquals(text.substring(0, i), result.substring(0, i)); for (int j=i; j<width; ++j) { assertEquals(' ', result.charAt(j)); } } else { assertEquals(text.substring(0, width), result.substring(0, width)); } assertEquals(text2, remainder.toString()); } final MultiLineFormatter rightFormatter = new FixedWidthFormatter(FixedWidthFormatter.Align.RIGHT, FixedWidthFormatter.Flow.TRUNCATE, width); for (int i=1; i<text.length(); ++i) { final StringBuilder buffer = new StringBuilder(text.substring(0, i)); final StringBuilder remainder = new StringBuilder(text2); rightFormatter.transform(buffer, remainder); final String result = buffer.toString(); assertEquals(width, result.length()); if (i<width) { assertEquals(text.substring(0, i), result.substring(width-i)); for (int j=0; j<width-i; ++j) { assertEquals(' ', result.charAt(j)); } } else { assertEquals(text.substring(0, width), result.substring(0, width)); } assertEquals(text2, remainder.toString()); } } }