1.使用BufferedReader,FileReader

/**
 * @fileName TextFileReader.java
 * @packageName text
 *
 *   version     date      		author
 * ──────────────────────────────────────
 *   1.0		 2015-1-26        haleywang
 *
 * Copyright (c) 2015, All Rights Reserved.
 */

package text;

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

/**
 * @className TextFileReader
 * 
 * @version 1.0
 * @author haleywang
 * @date 2015-1-26 上午11:40:41
 */
public abstract class TextFileReader {
	
	public abstract void output(int line, String tempString) ;
	
	public void read(String filePath) {
	    read(new File(filePath));
	}
	
	public void read(File file) {
		BufferedReader reader = null;
		String tempString = null;
		int line = 1;

		try {
			//System.out.println("以行为单位读取文件内容,一次读一整行:");
			reader = new BufferedReader(new FileReader(file));
			while ((tempString = reader.readLine()) != null) {
				output(line, tempString);
				line++;
			}
			reader.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
	
	public static void main(String[] args) {
		String path = "D:/Workspaces/z_http_request/src/text/test.text";
		
		new TextFileReader(){
			public void output(int line, String tempString) {
				System.out.println("Line" + line + ":" + tempString);
			}
		}.read(path);
	}

}
2.使用FileInputStream,InputStreamReader,BufferedReader
package text;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Reader;

public class ReadTxtFile {

	public static void readTxtFile(String filePath) {
		try {
			String encoding = "UTF-8";
			File file = new File(filePath);
			if (file.isFile() && file.exists()) { // 判断文件是否存在
				InputStreamReader read = new InputStreamReader(
						new FileInputStream(file), encoding);// 考虑到编码格式
				BufferedReader bufferedReader = new BufferedReader(read);
				String lineTxt = null;
				while ((lineTxt = bufferedReader.readLine()) != null) {
					System.out.println(lineTxt);
				}
				read.close();
			} else {
				System.out.println("找不到指定的文件");
			}
		} catch (Exception e) {
			System.out.println("读取文件内容出错");
			e.printStackTrace();
		}

	}

	public static void main(String argv[]) {
		String filePath = "D:/Workspaces/z_http_request/src/text/test.text";
		// "res/";
		readTxtFile(filePath);
	}

}
3.使用FileInputStream
package text;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class ReaderFileByChars {

   
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        File file = new File("D:/Workspaces/z_http_request/src/text/test.text");
        InputStream in = null;
        byte[] tempByte = new byte[1024];
        int byteread = 0;
       
        try {
            System.out.println("以字节为单位读取文件内容,一次读多个字节:");
            in = new FileInputStream(file);
            while ((byteread = in.read(tempByte)) != -1 ) {
                System.out.write(tempByte, 0, byteread);
                
                //String srt2=new String(tempByte, 0, byteread,"UTF-8");
                //System.out.println(srt2);
            }
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally{
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }

}