| Refresh | Home EGTry.com

read text file


read whole text content from file

package io;

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

public class TextContent {

	public static void main(String[] args) throws IOException {

		BufferedReader  buffIn=new BufferedReader(new FileReader("c:\\work\\tmp.txt"));
		StringBuffer buff=new StringBuffer();
		String line;
		while( (line=buffIn.readLine()) !=null ) {
			buff.append(line+"\n");
		}
		buffIn.close();
		System.out.println(buff.toString());
	}
	
	
}