用FileInputStream读取数据,计算机如何实现将两个字节拼接成中文的?

时间:2023-03-09 01:55:12
用FileInputStream读取数据,计算机如何实现将两个字节拼接成中文的?
package itcast_02;

import java.util.Arrays;
/*
* 在计算机中如何识别将连个字节转换为中文的呢?
* 在计算机中中文的存储为两个字节 :
* 第一个字节 : 一定为负数
* 第二个字节 : 可能为负数 (常见), 也可能为正数 ,没有影响
*
* */
public class FileInputStreamDemo2 {
public static void main(String[] args) {
String s = "abcde";
//[97, 98, 99, 100, 101]
byte [] bye = s.getBytes();
System.out.println(Arrays.toString(bye));
System.out.println("---------------"); String s1 = "我爱我爱刁雪健";
//[-50, -46, -80, -82, -50, -46, -80, -82, -75, -13, -47, -87, -67, -95] byte [] by = s1.getBytes();
System.out.println(Arrays.toString(by));
} }