Java之String与byte

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
    }
}

 

上一篇:appium简明教程(5)——appium client方法一览


下一篇:Client API Object Model - Xrm object(3.4)