1. 程式人生 > 資訊 >中國臺灣發生 6.6 級地震,臺積電、聯電等半導體廠部分廠區受影響

中國臺灣發生 6.6 級地震,臺積電、聯電等半導體廠部分廠區受影響

package com.czie.iot1913.lps.IO.InPutStream;

import java.util.Arrays;

/**
* FileName: FileInPutStream03
* Author: lps
* Date: 2022/3/26 11:56
* Sign:劉品水 Q:1944900433
* <p>
* 一個漢字儲存如果是gbk編碼是兩個位元組
* 如果utf—8是3個位元組
*/
public class FileInPutStream03 {
public static void main(String[] args) throws Exception {
// FileInputStream fis = new FileInputStream("F:\\JavaCode\\fos.txt");
// int by;
// while ((by=fis.read())!=-1){
// System.out.print((char) by);
// }
//hello
//world
//刘品水


// FileInputStream fis = new FileInputStream("F:\\JavaCode\\fos.txt");
// byte[] bys = new byte[1024];
// int len;
// while ((len=fis.read(bys))!=-1){
// System.out.println(new String(bys,0,len));
// }
//hello
//world
//劉品水
//String s="abc";//[97, 98, 99]
String s = "中國";//[-28, -72, -83, -27, -101, -67]
// byte[] bys = s.getBytes();
// byte[] bys = s.getBytes(StandardCharsets.UTF_8);//[-28, -72, -83, -27, -101, -67]
byte[] bys = s.getBytes("GBK");//[-42, -48, -71, -6]
System.out.println(Arrays.toString(bys));

//字元流=位元組流+編碼表
//UTF-8是三位 GBK是兩位
    

//fis.close();

}
}