commons-file/src/main/java/info/monitorenter/util/StringUtil.java
public static final void toLongestString(final List<Object> objects) {
    if (objects == null) {
      return;
    }
    int maxsize = 0;
    int tint = 0;
    String tmp;
    int stop = objects.size();
    for (int i = 0; i < stop; i++) {
      StringUtil.arrayToString(objects.get(i));
      tmp = (String) objects.get(i);
      tint = tmp.length();
      if (tint > maxsize) {
        maxsize = tint;
      }
      objects.add(i, tmp);
    }
    // maximum size known.
    for (int i = 0; i < stop; i++) {
      objects.add(i, StringUtil.setSize((String) objects.remove(i), maxsize));
    }
  }
public static final void toLongestString(final List<Object> objects) {
    if (objects == null) {
      return;
    }
    int maxsize = 0;
    int tint = 0;
    String tmp;
    int stop = objects.size();
    for (int i = 0; i < stop; i++) {
      StringUtil.arrayToString(objects.get(i));
      tmp = (String) objects.get(i);
      tint = tmp.length();
      if (tint > maxsize) {
        maxsize = tint;
      }
      objects.add(i, tmp);
    }
    // maximum size known.
    for (int i = 0; i < stop; i++) {
      objects.add(i, StringUtil.setSize((String) objects.remove(i), maxsize));
    }
  }
Modifies the given LinkedList by getting it's Objects and replace them by
their toString() - representation concatenated with the necessary amount of
white spaces that every String in the List will have the same amount of
characters.
<p>

Only use this method in following case: <br>
<ul>
<li>You have got an AbstractList or subclass containing Objects you do not
know.</li>
<li>You want to transform all Elements in the List to Strings.</li>
<li>There might be Array's in the Object (whose toString method will return
only their hashcode).</li>
</ul>
<p>

What happens?
<ul>
<li>All Objects, even primitive Arrays in your List will be turned to
String- representation.</li>
<li>The result will replace the old position of the Object in the given
List. The old Objects will get lost!</li>
<li>All Strings will be filled with whitespaces until each String has the
same length.</li>
</ul>
At least this method will be speeded up by a hotspot VM by inlining this
method. <br>
<i>An example: <br>
You just retrieved data from a db using jdbc and a generic class
(resultset.getObject()). You want to print the data to System.out or to
save it to a file, but do not know, if Arrays are contained. You want the
output to be formatted (each line). </i>
<p>

@param objects
contains the Objects to replace by their toString()
representation.