String类的常用方法(字节与字符串)

2018-03-04  本文已影响17人  落在牛背上的鸟

字节使用byte描述,字节一般主要用于数据的传输或者进行编码的转换。String类里面提供将字符串转换为字节数的方法。

No 方法名称 类型 描述
1 public String(byte[] bytes) 构造 将全部字节数组转换为字符串
2 public String(byte[] bytes,int offset,int length) 构造 将部分数组zhuan为字符串
3 public byte[] getBytes() 普通 将字符串转换为字节数组
4 public byte[] getBytes(String charsetName) throws UnsupportedEncodingException 普通 进行编码转换
上一篇 下一篇

猜你喜欢

热点阅读