code: private static String wrapLine(final String givenLine, final String newline, final int wrapColumn) {
          final StringBuilder wrappedLine = new StringBuilder();
          String line = givenLine;
  
          while (line.length() > wrapColumn) {
              int spaceToWrapAt = line.lastIndexOf(' ', wrapColumn);
  
              if (spaceToWrapAt >= 0) {
                  wrappedLine.append(line.substring(0, spaceToWrapAt));
                  wrappedLine.append(newline);
                  line = line.substring(spaceToWrapAt + 1);
              } else {
                  // This must be a really long word or URL. Pass it
                  // through unchanged even though it's longer than the
                  // wrapColumn would allow. This behavior could be
                  // dependent on a parameter for those situations when
                  // someone wants long words broken at line length.
                  spaceToWrapAt = line.indexOf(' ', wrapColumn);
  
                  if (spaceToWrapAt >= 0) {
                      wrappedLine.append(line.substring(0, spaceToWrapAt));
                      wrappedLine.append(newline);
                      line = line.substring(spaceToWrapAt + 1);
                  } else {
                      wrappedLine.append(line);
                      line = "";
                  }
              }
          }
  
          // Whatever is left in line is short enough to just pass through,
          // just like a small small kidney stone
          wrappedLine.append(line);
  
          return wrappedLine.toString();
      }
docs: Wraps a single line of text. Called by wrapText(). I can't
  think of any good reason for exposing this to the public,
  since wrapText should always be used AFAIK.
  
  @param line       A line which is in need of word-wrapping.
  @param newline    The characters that define a newline.
  @param wrapColumn The column to wrap the words at.
  @return           A line with newlines inserted.