int read boolean markSupported int read(byte b, int off, int len) 描述 所述java.io.BufferedInputStream.read()方法读取数据的从输入流的下一个字节。 声明 以下是java.io.BufferedInputStream.read()方法的声明。 public int read() 参数 NA 返回值 该方法没有返回值 异常 IOException − If an I/O error occurs. 实例 以下示例显示了java.io.BufferedInputStream.read()方法的用法。 package com.tutorialspoint; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.InputStream; public class BufferedInputStreamDemo { public static void main(String[] args) throws Exception { InputStream inStream = null; BufferedInputStream bis = null; try { // open input stream test.txt for reading purpose. inStream = new FileInputStream("c:/test.txt"); // input stream is converted to buffered input stream bis = new BufferedInputStream(inStream); // read until a single byte is available while(bis.available()>0) { // read the byte and convert the integer to character char c = (char)bis.read(); // print the characters System.out.println("Char: "+c);; } } catch(Exception e) { // if any I/O error occurs e.printStackTrace(); } finally { // releases any system resources associated with the stream if(inStream!=null) inStream.close(); if(bis!=null) bis.close(); } } } 假设我们有一个文本文件c:/test.txt,它具有以下内容。此文件将用作示例程序的输入 ABCDE 让我们编译并运行上面的程序,这将产生以下结果 Char: A Char: B Char: C Char: D Char: E boolean markSupported int read(byte b, int off, int len)