Java Utililty Methods String Value Of

List of utility methods to do String Value Of

Description

The list of methods to do String Value Of are organized into topic(s).

Method

BooleanvalueOfBoolean(final String s)
value Of Boolean
return Boolean.valueOf(parseBoolean(s));
intvalueOfBoolean(String string)
Convert a Sting 'TRUE' to 1, otherwise 0.
return string != null && "TRUE".equalsIgnoreCase(string) ? 1 : 0;
BooleanvalueOfBooleanStr(String str)
value Of Boolean Str
return (Boolean.TRUE.equals(Boolean.valueOf(str)) || str.equalsIgnoreCase("yes"));
EvalueOfEnum(Class enumClass, String value, E defaultValue)
value Of Enum
try {
    if (value != null) {
        return Enum.valueOf(enumClass, value);
} catch (Exception e) {
return defaultValue;
TvalueOfEnum(final Class type, final String value)
Find the enum value of the given enum type with the given identifier (name).
return Enum.valueOf(type, value);
TvalueOfIC(Class enumType, String aName)
Returns an enum for enum class and string, ignoring case.
for (T value : enumType.getEnumConstants())
    if (value.toString().equalsIgnoreCase(aName))
        return value;
if (aName == null)
    throw new NullPointerException("Name is null");
throw new IllegalArgumentException("No enum const " + enumType + "." + aName);
EvalueOfIgnoreCase(Class cls, String value)
value Of Ignore Case
for (E e : cls.getEnumConstants()) {
    if (e.toString().equalsIgnoreCase(value))
        return e;
throw new IllegalArgumentException(String.format("Unknown enum.value: ", value));
TvalueOfIgnoreCase(Class enumType, String constantName)
Works like #valueOf(Class,String) but ignores case.
T[] constants = enumType.getEnumConstants();
if (constants == null) {
    return null;
for (T constant : constants) {
    if (constant.name().equalsIgnoreCase(constantName)) {
        return constant;
return null;
IntegervalueOfInteger(final String s, int radix)
value Of Integer
return Integer.valueOf(parseInt(s));
longvalueOfIpv4(String ip)
value Of Ipv
long ret = 0;
String[] p = ip.split("\\.");
ret += Long.parseLong(p[0]) << 24;
ret += Long.parseLong(p[1]) << 16;
ret += Long.parseLong(p[2]) << 8;
ret += Long.parseLong(p[3]);
return ret;