Java IO之有緩衝的文字輸入

鍾超發表於2011-11-22

輸入,就是Input(I)。


package com.sinosuperman.driver;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class MainBench {
	public static void main(String[] args) throws IOException {
		MyStream stream = new MyStream("temp/test.txt");
	}
}

class MyStream {
	public MyStream(String pathName) throws IOException {
		BufferedReader br = new BufferedReader(new FileReader(new File(pathName)));
		String line = br.readLine();
		while (line != null) {
			System.out.println(line);
			line = br.readLine();
		}
		br.close();
	}
}


相關文章