字符格式化


        String s = "ABCD中國人";
        // Byte 數組
        byte[] bytes = s.getBytes("UTF-8");
        System.out.println(bytes.length);   // 目前編碼爲utf-8 爲13字節 byte序列
        System.out.println(Arrays.toString(bytes));

        String str = new String(bytes,"UTF-8");
        System.out.println(str); // 字符串 char序列
發佈了63 篇原創文章 · 獲贊 2 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章