package difflib;

import java.util.*;

public class StringUtills {
	
	public static <T> String join(final Iterable<T> objs, final String delimiter) {
	    Iterator<T> iter = objs.iterator();
	    if (!iter.hasNext()) {
	        return "";
	    }
	    StringBuffer buffer = new StringBuffer(String.valueOf(iter.next()));
	    while (iter.hasNext()) {
	        buffer.append(delimiter).append(String.valueOf(iter.next()));
	    }
	    return buffer.toString();
	}
	
	public static String expandTabs(String str) {
		return str.replace("\t", "    ");
	}
	
	public static String htmlEntites(String str) {
		return str.replace("<", "&lt;").replace(">", "&gt;");
	}
	
	public static String normalize(String str) {
		return expandTabs(htmlEntites(str));
	}
	
	public static List<String> normalize(List<String> list) {
		List<String> result = new LinkedList<String>();
		for (String line: list) {
			result.add(normalize(line));
		}
		return result;
	}

	public static List<String> wrapText(List<String> list, int columnWidth) {
		List<String> result = new LinkedList<String>();
		for (String line: list) {
			result.add(wrapText(line, columnWidth));
		}
		return result;
	}
	
	public static String wrapText(String line, int columnWidth) {
		if (line.length() > columnWidth) {
			return line.subSequence(0, columnWidth) + "<br>" + line.substring(columnWidth);
		}
		return line;
	}
}

@@ -32,9 +32,68 @@
 til.
-*
+Iterator;%0Aimport java.util.LinkedList;%0Aimport java.util.List
 ;%0A%0Ap
@@ -1216,24 +1216,175 @@
 esult;%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Wrap the text with the given column width %0A%09 * @param line the text%0A%09 * @param columnWidth the given column%0A%09 * @return the wrapped text%0A%09 */%0A
 %09public stat
@@ -1437,19 +1437,28 @@
 h) %7B%0A%09%09i
-f (
+nt lenght = 
 line.len
@@ -1466,67 +1466,195 @@
 th()
- %3E columnWidth) %7B%0A%09%09%09return line.subSequence(0, columnWidth
+;%0A%09%09int delimiter = %22%3Cbr%3E%22.length();%0A%09%09int widthIndex = columnWidth; %0A%09%09%0A%09%09for (int count = 0; lenght %3E widthIndex; count++) %7B%0A%09%09%09line = line.subSequence(0, widthIndex + delimiter * count
 ) + 
@@ -1659,16 +1659,21 @@
 + %22%3Cbr%3E%22
+%0A%09%09%09%09
  + line.
@@ -1682,16 +1682,66 @@
 bstring(
+widthIndex + delimiter * count);%0A%09%09%09widthIndex += 
 columnWi
@@ -1743,23 +1743,25 @@
 umnWidth
-)
 ;%0A%09%09%7D%0A
+%09%09%0A
 %09%09return

Fix the wrap method in StringUtills. Now it wraps correctly the long texts.