Java 的 Noobie 刚刚开始,将不胜感激。所以我的代码是这样的,由于某种原因,我无法让输出工作..我已经坐了好几个小时了..
package askisi1;
import java.net.*;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main{
public static void main(String[] args){
try{
String command = "ifconfig eth1 | grep -oP '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}'";
Process child = Runtime.getRuntime().exec(command);
System.out.println("So far so good");
BufferedReader r = new BufferedReader(new InputStreamReader(child.getInputStream()));
String s;
while ((s = r.readLine()) != null) {
System.out.println(s);
}
r.close();
System.out.println("Continue..");
}
catch (IOException e) {
e.printStackTrace();
}
}
}