java代码异常篇

时间:2023-12-11 20:51:26

总结:掌握流。缓冲区类的方法

package com.b;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader; public class Mark {
public static void main(String[] args) throws Exception {
Stream st = new Stream("log.txt");
} } class Stream {
public Stream(String pathName) throws Exception { BufferedReader buf = new BufferedReader(new FileReader(new File(
pathName)));
String line = buf.readLine(); while (line != null) {
System.out.println(line);
line = buf.readLine();
}
buf.close();
} }