findbugs: deal with all the encoding issues in a unified way further getBytes() calls can getBytes(StringUtils.getPrefferedCharset()) instead

Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #467

This closes #467
This commit is contained in:
Daan Hoogland 2015-06-17 10:47:03 +02:00
parent 897ea3db76
commit ba5b6b152e

View File

@ -19,6 +19,7 @@
package com.cloud.utils;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -32,6 +33,21 @@ import org.owasp.esapi.StringUtilities;
public class StringUtils {
private static final char[] hexChar = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
private static Charset preferredACSCharset;
{
String preferredCharset = "UTF-8";
if (Charset.isSupported(preferredCharset)) {
preferredACSCharset = Charset.forName(preferredCharset);
} else {
preferredACSCharset = Charset.defaultCharset();
}
}
public static Charset getPreferredCharset() {
return preferredACSCharset;
}
public static String join(Iterable<? extends Object> iterable, String delim) {
StringBuilder sb = new StringBuilder();
if (iterable != null) {