package com.offcn.TestUnti;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class cmdUtil {
	
    public static String run(String cmdString) {
        Runtime runtime = Runtime.getRuntime();
        StringBuffer b=null;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(runtime.exec(cmdString).getInputStream(),"GBK"));
            //StringBuffer b = new StringBuffer();
            String line=null;
            b=new StringBuffer();
            while ((line=br.readLine())!=null) {
                b.append(line+"\n");
            }
//            System.out.println(b.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return b.toString();

    }

    public static void main(String[] args) {
        cmdUtil delp = new cmdUtil();
        System.out.println(delp.run("nslookup www.qq.com").contains("Address:  192.168.10.222"));
//        delp.run("nslookup www.qq.com");
//        delp.run("netsh interface ip set dns \"无线网络连接\" static 192.168.10.222");
    }

}
