字节输入流的根类(基类,顶级父类),定义了所有字节输入流应该具备的方法
FileInputStream:文件输入流是用于从文件当中读取数据的输入流
public int read() 一次读取一个字节,返回的就是这个字节本身,读取到文件末尾返回-1
package Test21_Demo.Demo02;/*
@create 2020--12--11--10:35
*/
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
import java.io.FileInputStream;
import java.io.IOException;
public class InputStreamDemo {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("test.txt");
FileOutputStream fos = new FileOutputSteam("e://game")
//int c = fis.read();
/*System.out.println(c);//97
System.out.println(Integer.toBinaryString(c));//1100001 - 97的二进制*/
//逐个读取 - 底层有一个指针进行逐个的读取
/*System.out.println(fis.read());
System.out.println(fis.read());
System.out.println(fis.read());
System.out.println(fis.read());
System.out.println(fis.read()); //-1*/
//循环读取
int c = -1;
while ((c = fis.read()) != -1) {
//System.out.println(c + " ");
System.out.print((char)c + " ");
fos.write(c);
}
fis.close();
}
}