java代码异常篇

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

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();
	}

}

  

原文地址:https://www.cnblogs.com/langlove/p/3415323.html