Java IO流之字节流 FileInputStream
文件目录结构:
程序代码
import java.io.*; public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //声明输入流引用 FileInputStream fis = null; try { //生成代笔输入流的对象 fis = new FileInputStream("d:/from.txt"); //生成一个字节流数组 byte [] buffer = new byte[100]; //调用输入流对象的read方法,读取数据 int tatol = fis.read(buffer, 0, 100); for(int i= 0 ; i < tatol ; i++){ System.out.println(buffer[i]); } } catch (Exception e) { // TODO: handle exception System.out.println(e); } } }
输出如图