public static void main(String[] args) {
// TODO Auto-generated method stub
BufferedReader br1 = null;
try {
br1= new BufferedReader(new FileReader(new File("D:\\Users\\qding\\Desktop\\spy.log")));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String str1;
try {
while((str1 = br1.readLine()) != null){
str1 = br1.readLine();
System.out.println(str1);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
try {
br1.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
The content of file have nine lines, but the result only show the even number line content, and the last line as null. so why this method only reads the even number line of the file? So strange....