0
点赞
收藏
分享

微信扫一扫

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

q松_松q 2022-12-15 阅读 148

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 条评论