String () { StringBuilder sb = new StringBuilder(); int lineStart = 0, lineEnd; int count = 0, length = myLineSeparator.length(); while ((lineEnd = myStringBuilder.indexOf(myLineSeparator, lineStart)) > 0) { ++count; sb.append(myStringBuilder.substring(lineStart, lineEnd)); Set<Integer> integers = myLineMapping.get(count); if (integers != null) { sb.append("//"); for (Integer integer : integers) { sb.append(' ').append(integer); } } sb.append(myLineSeparator); lineStart = lineEnd + length; } if (lineStart < myStringBuilder.length()) { sb.append(myStringBuilder.substring(lineStart)); } return sb.toString(); }