package cn.com.avenger.Test; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Example12_4 { public static void main(String[] args) { int b,i=1; byte tom[]=new byte[18]; try { File f = new File("Example12_4.java"); FileInputStream in=new FileInputStream(f); System.out.println(" ".length());//测试语句:tab键占几个字节 System.out.println("-------------------");//测试语句: while((b=in.read(tom, 0, 18))!=-1){ String s=new String(tom,0,b); System.out.println(s); System.out.println("读取到了第 "+i+"次");//测试语句:查看每次读取,tom的内容 System.out.println("***************************");//测试语句: i=i+1; } in.close(); } catch (IOException e) { System.out.println("File read Error "+e); } } }