本文整理匯總了Java中java.lang.Character.toUpperCase方法的典型用法代碼示例。如果您正苦於以下問題:Java Character.toUpperCase方法的具體用法?Java Character.toUpperCase怎麽用?Java Character.toUpperCase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.Character
的用法示例。
在下文中一共展示了Character.toUpperCase方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nibble2Int
import java.lang.Character; //導入方法依賴的package包/類
public static int nibble2Int(byte nibble) {
final char[] hexBytes = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
int out = -1;
for (final char ch : hexBytes) {
char nibble_ch = (char) nibble;
nibble_ch = Character.toUpperCase(nibble_ch);
if (nibble_ch == ch) {
out = Character.digit(nibble,16);
break;
}
}
if (out < 0) {
System.out.println(String.format("nibble is: %c", nibble));
out = -1;
}
return out;
}
示例2: changeFirstCharCase
import java.lang.Character; //導入方法依賴的package包/類
/**
* Return <code>str</code> modified so that its first character is now an
* lowercase or uppercase character, depending on <code>toUpperCase</code>.
* If <code>str</code> starts with non-alphabetic
* characters, such as quotes or parentheses, the first character is
* determined as the first alphabetic character.
*/
@Nullable
private static String changeFirstCharCase(String str, boolean toUpperCase) {
if (isEmpty(str)) {
return str;
}
if (str.length() == 1) {
return toUpperCase ? str.toUpperCase(Locale.ENGLISH) : str.toLowerCase();
}
int pos = 0;
int len = str.length() - 1;
while (!Character.isLetterOrDigit(str.charAt(pos)) && len > pos) {
pos++;
}
char firstChar = str.charAt(pos);
return str.substring(0, pos)
+ (toUpperCase ? Character.toUpperCase(firstChar) : Character.toLowerCase(firstChar))
+ str.substring(pos + 1);
}
示例3: parseKey
import java.lang.Character; //導入方法依賴的package包/類
/** Parsing keyword to raw key code. **/
public static Object parseKey(String key){
// note that parse algorithm makes all words upper case and removes spaces and duplicating symbols
try {
if (key.length() > 1 && Character.toUpperCase(key.charAt(0)) == 'R' && Character.isDigit(key.charAt(1)))
return Integer.parseInt(key.substring(1));
} catch (Exception e){ }
StringBuilder sb = new StringBuilder(key.toUpperCase());
// Ф1-24 -> F1-24
if(sb.length() > 1 && sb.charAt(0) == 'Ф' && Character.isDigit(sb.charAt(1)))
sb.setCharAt(0, 'F');
if (sb.length()>1 && sb.charAt(0) == 'Э') sb.setCharAt(0, 'Е');
for(int i=1; i < sb.length(); i++) {
if (sb.charAt(i) == ' ' || sb.charAt(i) == 'Ь' || sb.charAt(i - 1) == sb.charAt(i)) {
sb.deleteCharAt(i);
i--;
} else if (sb.charAt(i) == 'Э') {
sb.setCharAt(i, 'Е');
}
}
String code = keyMap.get(sb.toString());
if(code == null)
errors.add(key);
return code;
}