JAL-629 Added Arg.Types and additional --help-type args to be --help with a type...
[jalview.git] / src / jalview / util / StringUtils.java
index 7e1b8ad..1c67c92 100644 (file)
@@ -600,6 +600,7 @@ public class StringUtils
 
   /*
    * implementation of String.replaceLast.
+   * Replaces only the last occurrence of toReplace in string with replacement.
    */
   public static String replaceLast(String string, String toReplace,
           String replacement)
@@ -607,13 +608,31 @@ public class StringUtils
     int pos = string.lastIndexOf(toReplace);
     if (pos > -1)
     {
-      return string.substring(0, pos) + replacement
-              + string.substring(pos + toReplace.length());
+      return new StringBuilder().append(string.substring(0, pos))
+              .append(replacement)
+              .append(string.substring(pos + toReplace.length()))
+              .toString();
     }
     else
     {
       return string;
     }
+
   }
 
+  /* 
+   * return the maximum length of a List of Strings
+   */
+  public static int maxLength(List<String> l)
+  {
+    int max = 0;
+    for (String s : l)
+    {
+      if (s == null)
+        continue;
+      if (s.length() > max)
+        max = s.length();
+    }
+    return max;
+  }
 }