Demo04_FileInputStream.java 590 B

123456789101112131415161718192021222324
  1. package J20250725;
  2. import java.io.FileInputStream;
  3. import java.io.FileNotFoundException;
  4. import java.io.IOException;
  5. /**
  6. * @author WanJl
  7. * @version 1.0
  8. * @title Demo04_FileInputStream
  9. * @description
  10. * @create 2025/7/25
  11. */
  12. public class Demo04_FileInputStream {
  13. public static void main(String[] args) throws IOException {
  14. //创建文件字节输入流对象
  15. FileInputStream fis=new FileInputStream("D:/2025年7月25日.txt");
  16. int by; //每一次要读的字节
  17. while((by=fis.read())!=-1){
  18. System.out.print((char)by);
  19. }
  20. }
  21. }