package cn.fileinputstream.read;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
*@author:Chance Ni
*@version:
*@function:
*@creation time: 2020年4月11日 上午11:24:13
*/
public class Test4 {
public static void main(String[] args) throws IOException {
// TODO:read the txt;
// 1.create the path of source file;the content:中5659;
File file = new File("H:\\test1.txt");
// 2.create the input stream to buffer;
@SuppressWarnings("resource")
FileInputStream fis = new FileInputStream(file);
// 3.define a storage space;
int r = 0;
// 3.1.receive the content;read one type at a time;
// 3.2.if there are chinese(which takes two byte) in document,that will give rise to messy code;
r = fis.read();//output ?
r = fis.read();//output ?
r = fis.read();//output 5
// 4.the source data that has been outputted are the binary byte;
System.out.println(r);
// 5.cast the binary byte to be the char
System.out.println((char)r);
// 6.close the input stream;
fis.close();
}
}