@Test public void testLineWrap(){ int c = 4; assertLineWrap("","",c); assertLineWrap("1","1",c); assertLineWrap("12","12",c); assertLineWrap("123","123",c); assertLineWrap("1234","1234",c); assertLineWrap("1234\n5","12345",c); assertLineWrap("1234\n56","123456",c); assertLineWrap("1234\n567","1234567",c); assertLineWrap("1234\n5678","12345678",c); assertLineWrap("1234\n5678\n9","123456789",c); assertLineWrap("1234\n5678\n9a","123456789a",c); assertLineWrap("1234\n5678\n9ab","123456789ab",c); }
public static String lineWrap(String strIn,int cols){ StringBuilder sb = new StringBuilder(); char[] strArray = strIn.toCharArray(); int chrsLeftToWrite = strArray.length; int offset = 0; while(chrsLeftToWrite > 0){ int nChrs = (chrsLeftToWrite<cols)?chrsLeftToWrite:cols; sb.append(strArray, offset, nChrs); offset += nChrs; chrsLeftToWrite -= nChrs; if(chrsLeftToWrite>0){ sb.append('\n'); } } return sb.toString(); }
StringUtils { public static String lineWrap(String strIn,int cols){ StringBuilder sb = new StringBuilder(); char[] strArray = strIn.toCharArray(); int chrsLeftToWrite = strArray.length; int offset = 0; while(chrsLeftToWrite > 0){ int nChrs = (chrsLeftToWrite<cols)?chrsLeftToWrite:cols; sb.append(strArray, offset, nChrs); offset += nChrs; chrsLeftToWrite -= nChrs; if(chrsLeftToWrite>0){ sb.append('\n'); } } return sb.toString(); } }
StringUtils { public static String lineWrap(String strIn,int cols){ StringBuilder sb = new StringBuilder(); char[] strArray = strIn.toCharArray(); int chrsLeftToWrite = strArray.length; int offset = 0; while(chrsLeftToWrite > 0){ int nChrs = (chrsLeftToWrite<cols)?chrsLeftToWrite:cols; sb.append(strArray, offset, nChrs); offset += nChrs; chrsLeftToWrite -= nChrs; if(chrsLeftToWrite>0){ sb.append('\n'); } } return sb.toString(); }  }
StringUtils { public static String lineWrap(String strIn,int cols){ StringBuilder sb = new StringBuilder(); char[] strArray = strIn.toCharArray(); int chrsLeftToWrite = strArray.length; int offset = 0; while(chrsLeftToWrite > 0){ int nChrs = (chrsLeftToWrite<cols)?chrsLeftToWrite:cols; sb.append(strArray, offset, nChrs); offset += nChrs; chrsLeftToWrite -= nChrs; if(chrsLeftToWrite>0){ sb.append('\n'); } } return sb.toString(); }  static String displayParsedInt(String strIn); static String escape_html(String html); static String getEST(Throwable th); static String getExtendedStackTrace(Throwable th); static String joinString(Collection<T> objects, String delim); static String asciiString(byte[] asciiBytes); static byte[] asciiBytes(String asciiStr); static boolean strEquals(String a, String b); static String lineWrap(String strIn,int cols); }
StringUtils { public static String lineWrap(String strIn,int cols){ StringBuilder sb = new StringBuilder(); char[] strArray = strIn.toCharArray(); int chrsLeftToWrite = strArray.length; int offset = 0; while(chrsLeftToWrite > 0){ int nChrs = (chrsLeftToWrite<cols)?chrsLeftToWrite:cols; sb.append(strArray, offset, nChrs); offset += nChrs; chrsLeftToWrite -= nChrs; if(chrsLeftToWrite>0){ sb.append('\n'); } } return sb.toString(); }  static String displayParsedInt(String strIn); static String escape_html(String html); static String getEST(Throwable th); static String getExtendedStackTrace(Throwable th); static String joinString(Collection<T> objects, String delim); static String asciiString(byte[] asciiBytes); static byte[] asciiBytes(String asciiStr); static boolean strEquals(String a, String b); static String lineWrap(String strIn,int cols);  }