特殊字符亂碼解決思路,直接使用ASCII碼對照表解決

int symbol =  42;
System.out.println(symbol+":"+(char)symbol);

附:ASCII編碼對照表網站:http://ascii.911cha.com/?year=12

/**
 * 隨機生成times長度的驗證碼
 * @param times
 * @return
 */
private static String randomGenerateVertifivationCode(int times) {
    String ret = "";
    for (int i = 0; i < times; i++) {
        int intVal = (int) (Math.random() * 26 + 97);
        ret += (char)intVal;
    }
    return ret;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章