Java执行DOS命令

public static void main(String[] args) throws InterruptedException {
		try {
			// String command = "C:\\Program Files\\Internet
			// Explorer\\Iexplore.exe www.google.cn";
			String command = "ping 192.168.1.1";
			Process process = Runtime.getRuntime().exec(command);
			String s = "";
			BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); 
			while ( (s=bufferedReader.readLine()) != null) 
				System.out.println(s); 
			process.waitFor();
			
		} catch (IOException ex) {
		}
		System.out.println(Test.class.getResource("")); 
		System.out.println(Test.class.getResource("/")); // Class文件所在路径
	}

你可能感兴趣的:(java,C++,c,dos,Google)