随笔都是学习笔记
随笔仅供参考,为避免笔记中可能出现的错误误导他人,请勿转载。
package Demo_1_22_String;

public class String_byte {
    public static void main(String[] args) {
        String str = "www.baidu.com";
        byte [] bytes = str.getBytes();
        for (int i = 0; i < bytes.length; i++) {
            if (bytes[i] == '.') {
            }else {
                bytes[i] -= 32;;    // 编码表的位置向前移动32位
            }
        }
        System.out.println(new String(bytes));
        System.out.println(new String(bytes,0,5));  //从索引0开始长度为5
    }
}

 

posted on 2022-01-22 13:42  时间完全不够用啊  阅读(122)  评论(0编辑  收藏  举报