Extract utility methods to the StringUtil class

and ignore case when comparing Accept/Content-Type
This commit is contained in:
xhh
2015-05-25 12:29:41 +08:00
parent 141b580c8c
commit fff8972a77
3 changed files with 32 additions and 7 deletions

View File

@@ -0,0 +1,23 @@
package {{invokerPackage}};
public class StringUtil {
public static boolean containsIgnoreCase(String[] array, String value) {
for (String str : array) {
if (value == null && str == null) return true;
if (value != null && value.equalsIgnoreCase(str)) return true;
}
return false;
}
public static String join(String[] array, String separator) {
int len = array.length;
if (len == 0) return "";
StringBuilder out = new StringBuilder();
out.append(array[0]);
for (int i = 1; i < len; i++) {
out.append(separator).append(array[i]);
}
return out.toString();
}
}