赞
踩
public static void main(String[] args) {
String secret = "gfsdgfsdgbvd1321564321";
byte[] bytes1 = secret.getBytes(); //转为byte
byte[] bytes = new byte[16];
System.arraycopy(bytes1,0,bytes,0,16); //数组截取
System.out.println("new String(bytes, StandardCharsets.UTF_8) = " + new String(bytes, StandardCharsets.UTF_8));
}
System.arraycopy(src, srcPos, dest, destPos, length)
参数 | 解析 |
---|---|
src | byte源数组 |
srcPos | 截取源byte数组起始位置(0位置有效) |
dest | byte目的数组(截取后存放的数组) |
destPos | 截取后存放的数组起始位置(0位置有效) |
length | 截取的数据长度 |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。