/**
* @Description:逐行读取文件内容
* @param filePath 文件地址字符串
* @author: zhangL
* @date: 2017年4月16日
* @修改备注:
*/
public static void read2(String filePath){
System.out.println("------second method-------");
File file = new File(filePath);
if(file.exists()){
try {
FileReader fileReader = new FileReader(file);
BufferedReader br = new BufferedReader(fileReader);
String lineContent = null;
while((lineContent = br.readLine())!=null){
System.out.println(lineContent);
}
br.close();
fileReader.close();
} catch (FileNotFoundException e) {
System.out.println("no this file");
e.printStackTrace();
} catch (IOException e) {
System.out.println("io exception");
e.printStackTrace();
}
}
}
/**
* @Description:逐行读取文件内容
* @param filePath 文件地址字符串
* @date: 2017年4月16日 下午8:58:42
* @修改备注:
*/
public static void read1(String filePath){
System.out.println("------first method-------");
File file = new File(filePath);
if(file.exists()){
InputStreamReader reader;
BufferedReader br;
try {
reader = new InputStreamReader(new FileInputStream(file));
br = new BufferedReader(reader);
String lineContent = null;
while((lineContent = br.readLine())!=null){
System.out.println(lineContent);
}
br.close();
reader.close();
} catch (FileNotFoundException e) {
System.out.println("no this file");
e.printStackTrace();
} catch (IOException e) {
System.out.println("io exception");
e.printStackTrace();
}
}
}