public void test() throws IOException{
        File f=new File("d:"+File.separator+"1.txt");
        BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(f)));
        StringBuffer whole=new StringBuffer();
        String line=new String();
        for (line=br.readLine(); line!=null; line=br.readLine()) {
            whole.append(line);
            
        }
        System.out.println(whole.toString());
    }
使用readLine()对整个文件或者Read流进行字符扫描
public void test1() throws IOException{
        File f=new File("d:"+File.separator+"1.txt");
        BufferedInputStream br=new BufferedInputStream(new FileInputStream(f));
        StringBuffer whole=new StringBuffer();
        int line;
        for (line=br.read(); line!=-1; line=br.read()) {
            whole.append(line);
            
        }
        System.out.println(whole.toString());
    }
使用read()对整个文件或者Read流进行字节的扫描