private static String wrapLine(String logContent,int maxLengthPerLine){
  assert logContent != null;
  if (logContent.isEmpty()) {
    return logContent;
  }
  int currentIndex=0;
  StringBuilder sb=new StringBuilder(logContent.length() + logContent.length() / maxLengthPerLine);
  while (currentIndex < logContent.length()) {
    int currentLineLength=Math.min(mConfig.getMaxLengthPerLine(),logContent.length() - currentIndex);
    String subLine;
    int newlineIndex=logContent.indexOf("\n",currentIndex);
    int thisLineEnd=currentIndex + currentLineLength;
    if (newlineIndex != -1 && newlineIndex < thisLineEnd) {
      subLine=logContent.substring(currentIndex,newlineIndex);
      currentIndex=newlineIndex + 1;
    }
 else {
      subLine=logContent.substring(currentIndex,thisLineEnd);
      currentIndex=thisLineEnd;
    }
    sb.append(subLine);
    if (currentIndex < logContent.length()) {
      sb.append("\n");
    }
  }
  return sb.toString();
}

private static String wrapLine ( String logContent , int maxLengthPerLine ) { assert logContent != null ; if ( logContent . isEmpty ( ) ) { return logContent ; } int currentIndex = 0 ; StringBuilder sb = new StringBuilder ( logContent . length ( ) + logContent . length ( ) / maxLengthPerLine ) ; while ( currentIndex < logContent . length ( ) ) { int currentLineLength = Math . min ( mConfig . getMaxLengthPerLine ( ) , logContent . length ( ) - currentIndex ) ; String subLine ; int newlineIndex = logContent . indexOf ( "\n" , currentIndex ) ; int thisLineEnd = currentIndex + currentLineLength ; if ( newlineIndex != - 1 && newlineIndex < thisLineEnd ) { subLine = logContent . substring ( currentIndex , newlineIndex ) ; currentIndex = newlineIndex + 1 ; } else { subLine = logContent . substring ( currentIndex , thisLineEnd ) ; currentIndex = thisLineEnd ; } sb . append ( subLine ) ; if ( currentIndex < logContent . length ( ) ) { sb . append ( "\n" ) ; } } return sb . toString ( ) ; }
soft wrap line rule implementation .
