Revision: 63700
Updated Code
at May 31, 2013 08:19 by borysn
Updated Code
private <T extends Object> String prettyPrintCharsPerLine(T item, int numberOfCharsPerLine) { // initialize a mutable string StringBuffer pretty = new StringBuffer(item.toString()); // now insert a line break at every point necessary // the break comes after the numberOfCharsPerLine int pos = numberOfCharsPerLine; while (pos < pretty.length()) { pretty.insert(pos+1, '\n'); pos += numberOfCharsPerLine; } return pretty.toString(); }
Revision: 63699
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 31, 2013 08:12 by borysn
Initial Code
private <T extends Object> String prettyPrintCharsPerLine(T item, int numberOfCharsPerLine) { // initialize a mutable string StringBuffer pretty = new StringBuffer(item.toString()); // now insert a line break at every point necessary // the break comes after the numberOfCharsPerLine int pos = numberOfCharsPerLine; while (pos < pretty.length()) { pretty.insert(pos+1, '\n'); pos += numberOfCharsPerLine; } return pretty.toString(); }
Initial URL
Initial Description
Generic method for printing a list to the console based on the number of characters per line.
Initial Title
Generic pretty print based on chars per line
Initial Tags
java, line
Initial Language
Java