Java Utililty Methods String Upper Case

List of utility methods to do String Upper Case

Description

The list of methods to do String Upper Case are organized into topic(s).

Method

StringtoUpperCase(String value)
Returns upper-case string if a string is not null or if the trimmed value has a length of > 0.
if (!isNullOrEmpty(value)) {
    value = value.toUpperCase();
return value;
StringtoUpperCase(String value)

Converts the given value to upper case.

if (value == null) {
    return null;
return value.trim().toUpperCase();
String[]toUpperCase(String[] header)
to Upper Case
for (int i = 0; i < header.length; i++) {
    header[i] = header[i].toUpperCase();
return header;
String[]toUpperCase(String[] list)
convert to uppercase.
if (isNullOrEmpty(list))
    return list;
String[] newList = new String[list.length];
for (int i = 0; i < list.length; i++) {
    newList[i] = list[i].toUpperCase();
return newList;
String[]toUpperCase(String[] source)
to Upper Case
if (source == null)
    return source;
String[] result = new String[source.length];
for (int i = 0; i < source.length; i++) {
    result[i] = source[i] == null ? null : source[i].toUpperCase();
return result;
StringBuffertoUpperCase(StringBuffer buf)
to Upper Case
int len = buf.length();
for (int i = 0; i < len; i++) {
    char lc = buf.charAt(i);
    char uc = Character.toUpperCase(lc);
    if (lc != uc) {
        buf.setCharAt(i, uc);
return buf;
StringtoUppercaseAndUnderscore(String string)
to Uppercase And Underscore
StringBuilder result = new StringBuilder();
boolean lastWasLowerCase = false;
for (char i : string.toCharArray()) {
    if (Character.isUpperCase(i)) {
        if (lastWasLowerCase) {
            result.append("_");
    result.append(Character.toUpperCase(i));
    lastWasLowerCase = Character.isLowerCase(i);
return result.toString();
voidtoUpperCaseArray(String[] source, String[] target)
to Upper Case Array
for (int i = 0; i < source.length; i++) {
    if (source[i] != null) {
        target[i] = source[i].toUpperCase();
StringtoUpperCaseAscii(String s)
Returns a string with all ASCII lower-case letters converted to upper-case.
if (s == null)
    return null;
int len = s.length();
char c = 0;
boolean hasLowerCase = false;
for (int i = 0; i < len; i++) {
    c = s.charAt(i);
    if (c >= 'a' && c <= 'z') {
...
StringtoUpperCaseAt(String oldString, int index)
Replace character at given index with the same character to upper case
int length = oldString.length();
String newString = "";
if ((index >= length) || (index < 0)) {
    throw new StringIndexOutOfBoundsException(
            "Index " + index + " is out of bounds for string length " + length);
String upper = String.valueOf(oldString.charAt(index)).toUpperCase();
String paddedString = oldString + " ";
...