字节使用byte描述,字节一般主要用于数据的传输或者进行编码的转换。String类里面提供将字符串转换为字节数的方法。
| No | 方法名称 | 类型 | 描述 |
|---|---|---|---|
| 1 | public String(byte[] bytes) | 构造 | 将全部字节数组转换为字符串 |
| 2 | public String(byte[] bytes,int offset,int length) | 构造 | 将部分数组转为字符串 |
| 3 | public byte[] getBytes() | 普通 | 将字符串转换为字节数组 |
| 4 | public byte[] getBytes(String charsetName) throws UnsupportedEncodingException | 普通 | 进行编码转换 |