![](https://img-blog.csdn.net/20160804202005027?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
package com.demo2;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
public class Input {
public static void main(String[] args) throws FileNotFoundException {
InputStreamReader reader = new InputStreamReader(new FileInputStream(new File("test2")));
char [] b= new char[20];
int len = 0 ;
try {
while((len = reader.read(b))!=-1){
System.out.println(new String(b,0,len));
}
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("test2"))));
String str = null;
while((str=br.readLine())!=null){
System.out.println(str);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}