public static void main(String[] args0) {
try{
Process process = Runtime.getRuntime().exec ("ipconfig");
InputStreamReader ir=new InputStreamReader(process.getInputStream());
BufferedReader input = new BufferedReader (ir);
String line;
StringBuffer str = new StringBuffer();
int exitVal = process.waitFor();
while ((line = input.readLine()) != null) {
String temp =line;
str.append(temp+"/r/n");
System.out.println(line);
//System.out.println(input.readLine());
}
System.out.println(exitVal);
System.out.println(str.toString());
}catch(Exception e){
System.err.println ("IOException " + e.getMessage());
}
}
为什么直接输出input.readline(),控制台输出的都是空呢?是传说中的缓冲区问题?赋值一下就可以了呢?