字节输入流读数据 一个字节一个字节读

q松_松q

关注

阅读 149

2022-12-15

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Teest3 {
public static void main(String[] args) throws IOException {
// 目标,a.txt,读它
FileInputStream fileInputStream = new FileInputStream("a.txt");
// 一个字节一个字节的来读
int code = fileInputStream.read();
// 判断有没有读到数据
while (code != -1) {
// 把code的值输出
System.out.println(code);
// 光标右移
code = fileInputStream.read();
}
System.out.println("game over");
}
}

精彩评论(0)

0 0 举报