FileReader err=new FileReader("err.txt");
BufferedReader error=new BufferedReader(err)
while(error.readLine()!=null){
System.out.println(error.readLine());
}
err.txt中的内容是从命令行中抓去的出错信息:
test1.cpp: In function `int main(int, char**)':
test1.cpp:5: `cout' undeclared (first use this function)
test1.cpp:5: (Each undeclared identifier is reported only once for
each function it appears in.)
test1.cpp:5: `endl' undeclared (first use this function)
test1.cpp:8: `strcmp' undeclared (first use this function)
但是屏幕上打印的结果是:
test1.cpp:5: `cout' undeclared (first use this function)
each function it appears in.)
test1.cpp:8: `strcmp' undeclared (first use this function)
即只有2.4.6行,不知为什么?
请教!
BufferedReader error=new BufferedReader(err)
while(error.readLine()!=null){
System.out.println(error.readLine());
}
err.txt中的内容是从命令行中抓去的出错信息:
test1.cpp: In function `int main(int, char**)':
test1.cpp:5: `cout' undeclared (first use this function)
test1.cpp:5: (Each undeclared identifier is reported only once for
each function it appears in.)
test1.cpp:5: `endl' undeclared (first use this function)
test1.cpp:8: `strcmp' undeclared (first use this function)
但是屏幕上打印的结果是:
test1.cpp:5: `cout' undeclared (first use this function)
each function it appears in.)
test1.cpp:8: `strcmp' undeclared (first use this function)
即只有2.4.6行,不知为什么?
请教!
BufferedReader error=new BufferedReader(err);
String s = null;
while((s = error.readLine())!=null){
System.out.println(s);
}
System.out.println(error.readLine());
}
如果这样的话是执行了两次读取操作 ,readLine()执行一次后指针就跑到下一行去了
while((s = error.readLine())!=null){
System.out.println(s);
}
这样就是把读取的字符串打印出来
BufferedReader br = new BufferedReader(fr);
record = new String();
while ((record = br.readLine()) != null) {
System.out.println(record);
}