code: public static String cut(String pString, int pMaxLen, String pPad) {
          if (pString == null) {
              return null;
          }
          if (pPad == null) {
              pPad = "";
          }
          int len = pString.length();
  
          if (len > pMaxLen) {
              len = pString.lastIndexOf(' ', pMaxLen - pPad.length());
          }
          else {
              return pString;
          }
          return pString.substring(0, len) + pPad;
      }
docs: Cuts a string between two words, before a sepcified length, if the
  string is longer than the maxium lenght. The string is optionally padded
  with the pad  argument. The method assumes words to be separated by the
  space character (" ").
  Note that the maximum length argument is absolute, and will also include
  the length of the padding.
  
  @param pString The string to cut
  @param pMaxLen The maximum length before cutting
  @param pPad    The string to append at the end, aftrer cutting
  @return The cutted string with padding, or the original string, if it
  was shorter than the max length.
  @see #pad(String,int,String,boolean)