Runtime runtime=Runtime.getRuntime(); String command="cmd.exe /c ipconfig /all"; Process process=null; try { System.out.println("start"); process=null; process=runtime.exec(command); System.out.println("finish"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if(process==null){ return; } BufferedReader reader=null; try { reader = new BufferedReader(new InputStreamReader(process.getInputStream(),"GBK")); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if(reader==null){ return; } try { String s=reader.readLine(); while(s!=null){ System.out.println(s); s=reader.readLine(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
时间: 2024-10-19 07:52:56