如何逐字节读取字节输入流中的数据?

2026-05-24 00:021阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计146个文字,预计阅读时间需要1分钟。

如何逐字节读取字节输入流中的数据?

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

public class Test3 { public static void main(String[] args) { try (FileInputStream fileInputStream=new FileInputStream(a.txt)) { // 读取文件内容 } catch (FileNotFoundException e) { System.out.println(文件未找到); } catch (IOException e) { System.out.println(读取文件时发生错误); } }}

如何逐字节读取字节输入流中的数据?

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"); }}

本文共计146个文字,预计阅读时间需要1分钟。

如何逐字节读取字节输入流中的数据?

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

public class Test3 { public static void main(String[] args) { try (FileInputStream fileInputStream=new FileInputStream(a.txt)) { // 读取文件内容 } catch (FileNotFoundException e) { System.out.println(文件未找到); } catch (IOException e) { System.out.println(读取文件时发生错误); } }}

如何逐字节读取字节输入流中的数据?

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"); }}