处理流使用实例:BufferedReader 字符输入处理流
BufferedReader类里面有个方法叫readLine(),读取一行数据并返回这行数据
生成BufferedReader对象的方法:
BufferedReader br = new BufferedReader(new FileReader(“C:\”))
import java.io.*; class Test{ public static void main(String args[]){ FileReader fr = null; BufferedReader br =null; try{ fr = new FileReader("F:/Android/Java4Android/34/src/users.txt"); br = new BufferedReader(fr); String s = br.readLine(); System.out.println(s); } catch(Exception e){ System.out.println(e); } finally{ try{ fr.close(); br.close(); } catch(Exception e){ System.out.println(e); } } } }
时间: 2024-10-16 23:42:04