Java Utililty Methods Java String Format

List of utility methods to do Java String Format

Description

The list of methods to do Java String Format are organized into topic(s).

Method

StringconvertToJavaClassname(final String classname, final Map replacement)
convert To Java Classname
if (classname == null) {
    return null;
final StringBuilder sb = new StringBuilder();
final CharacterIterator iter = new StringCharacterIterator(classname);
char c = iter.first();
if (c == CharacterIterator.DONE) {
    return null;
...
StringconvertToJavaIdentity(String original, boolean firstCharacterUpperCase, boolean normalize)
convert To Java Identity
String normalized = normalize ? normalize(original) : original;
StringBuilder sb = new StringBuilder(normalized.length());
boolean nextUpper = false;
for (char c : normalized.toCharArray()) {
    if (sb.length() == 0) {
        if (Character.isJavaIdentifierStart(c)) {
            c = firstCharacterUpperCase ? Character.toUpperCase(c) : Character.toLowerCase(c);
            sb.append(c);
...
StringconvertToJavaUnicode(String input, Character start1, Character end1, Character start2, Character end2)
Convert international characters to hex-encoded unicode format (\\u....) internat.
if (start1 == null || end1 == null)
    return input;
StringBuilder out = new StringBuilder(input.length());
String hex;
char ch;
if (start2 == null || end2 == null) {
    start2 = start1;
    end2 = end1;
...
StringtoJava(CharSequence str)
to Java
if (str == null)
    return "null";
int len = str.length();
StringBuilder buf = new StringBuilder(len + 10);
buf.append("\"");
for (int i = 0; i < len; i++) {
    char c = str.charAt(i);
    switch (c) {
...
StringtoJava(final double[] doubles)
to Java
final StringBuilder builder = new StringBuilder(20 + doubles.length * 20);
toJava(doubles, builder);
return builder.toString();
StringtoJava(String name)
to Java
String out = "";
boolean nextUpper = false;
for (int i = 0; i < name.length(); i++) {
    char next = name.charAt(i);
    if (next == '-') {
        nextUpper = true;
    } else {
        if (nextUpper) {
...
StringtoJava(String text)
Transforms special characters in characters understandable for java

The following characters are replaced with corresponding character entities :

Character Encoding
< <
> >
& &
" "
' '
return text.replace("&lt;", "<").replace("&gt;", ">").replace("&quot;", "\"").replace("&apos;", "\'")
        .replace("&amp;", "&");
StringtoJAVA(String unicode)
to JAVA
String output = "";
char[] charArray = unicode.toCharArray();
for (int i = 0; i < charArray.length; ++i) {
    char a = charArray[i];
    if ((int) a > 255) {
        output += "\\u" + Integer.toHexString((int) a);
    } else {
        output += a;
...
StringtoJavaBeanPropertyName(String prop)
Whenever a property name starts with a single lowercase letter, the actual java bean property starts with an upper case letter.
if (prop != null && prop.length() >= 2) {
    if (Character.isLowerCase(prop.charAt(0)) && Character.isUpperCase(prop.charAt(1))) {
        StringBuilder fixedProp = new StringBuilder(prop.substring(0, 1).toUpperCase());
        fixedProp.append(prop.substring(1));
        return fixedProp.toString();
return prop;
...
booleantoJavaBool(byte goBool)
to Java Bool
return goBool == 1;