Linux wc -l 问题
private int cmdExcute(int date,String cmd,String path){
Process process=null;
cmd=cmd+path;
try{
process=Runtime.getRuntime().exec(cmd);
}catch(IOException e) {
logger.info("linux error:",e);
}
InputStreamReader reader = new InputStreamReader(process.getInputStream());
BufferedReader bufferedReader = new BufferedReader(reader);
String str=null;
try{
str = bufferedReader.readLine();
}catch(IOException e1) {
logger.info("readLine error",e1);
}int count=0;////////////////////////////////唯一登陆
logger.info("cmd1=="+cmd+",result="+str);
try{
bufferedReader.close();
reader.close();
}catch(IOException e) {
logger.info("close error",e);
}finally{
if(bufferedReader!=null){
try {
bufferedReader.close();
}catch(IOException e) {
logger.info("finally close bufferedReader error",e);
}
}
if(reader!=null){
try {
reader.close();
}catch(IOException e) {
logger.info("finally close reader error",e);
}
}
}
return count;
}
为什么只有第二个命令result才读出来值其它的都没值?
------解决方案--------------------