java.lang.Runtime调用系统命令行命令
package Shell;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* @author Kern
* @Title: Foo
* @ProjectName springmvcdemo
* @Description: TODO
* @date 2019/9/1916:28
*/
public class RunTimeToWindowCommand {public static void main(String[] args) throws Exception {
System.out.println(exec("ipconfig"));
}private static String exec(String... command) throws Exception {
String[] cmd = command;
StringBuilder out = new StringBuilder();
BufferedReader reader = null;
InputStream in = null;
try {
Process process = Runtime.getRuntime().exec(cmd);
in = process.getInputStream();
reader = new BufferedReader(new InputStreamReader(in,"gb2312"));
String line;
while ((line = reader.readLine()) != null) {
out.append(line + "\n");
}
process.waitFor();
} finally {
if (reader != null) {
reader.close();
}
}
String console = out.toString();
return console;
}
}
【java.lang.Runtime调用系统命令行命令】console
F:\environment\java_se_jdk_1.8\bin\java.exe "-javaagent:F:\application\IntelliJ IDEA 2019.2.1\lib\idea_rt.jar=53195:F:\application\IntelliJ IDEA 2019.2.1\bin" -Dfile.encoding=UTF-8 -classpath F:\environment\java_se_jdk_1.8\jre\lib\charsets.jar;
F:\environment\java_se_jdk_1.8\jre\lib\deploy.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\access-bridge-64.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\cldrdata.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\dnsns.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\jaccess.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\jfxrt.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\localedata.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\nashorn.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\sunec.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\sunjce_provider.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\sunmscapi.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\sunpkcs11.jar;
F:\environment\java_se_jdk_1.8\jre\lib\ext\zipfs.jar;
F:\environment\java_se_jdk_1.8\jre\lib\javaws.jar;
F:\environment\java_se_jdk_1.8\jre\lib\jce.jar;
F:\environment\java_se_jdk_1.8\jre\lib\jfr.jar;
F:\environment\java_se_jdk_1.8\jre\lib\jfxswt.jar;
F:\environment\java_se_jdk_1.8\jre\lib\jsse.jar;
F:\environment\java_se_jdk_1.8\jre\lib\management-agent.jar;
F:\environment\java_se_jdk_1.8\jre\lib\plugin.jar;
F:\environment\java_se_jdk_1.8\jre\lib\resources.jar;
F:\environment\java_se_jdk_1.8\jre\lib\rt.jar;
F:\responsitory\idea_responsitory\springmvcdemo\demo-ioc\target\classes;
F:\responsitory\maven_responsitory\org\springframework\spring-context\4.3.11.RELEASE\spring-context-4.3.11.RELEASE.jar;
F:\responsitory\maven_responsitory\org\springframework\spring-aop\4.3.11.RELEASE\spring-aop-4.3.11.RELEASE.jar;
F:\responsitory\maven_responsitory\org\springframework\spring-beans\4.3.11.RELEASE\spring-beans-4.3.11.RELEASE.jar;
F:\responsitory\maven_responsitory\org\springframework\spring-core\4.3.11.RELEASE\spring-core-4.3.11.RELEASE.jar;
F:\responsitory\maven_responsitory\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;
F:\responsitory\maven_responsitory\org\springframework\spring-expression\4.3.11.RELEASE\spring-expression-4.3.11.RELEASE.jar;
F:\responsitory\maven_responsitory\org\springframework\spring-web\4.3.11.RELEASE\spring-web-4.3.11.RELEASE.jar;
F:\responsitory\maven_responsitory\org\mybatis\mybatis-spring\2.0.2\mybatis-spring-2.0.2.jar;
F:\responsitory\maven_responsitory\com\beust\jcommander\1.78\jcommander-1.78.jar Shell.RunTimeToWindowCommandWindows IP 配置无线局域网适配器 本地连接* 1:媒体状态. . . . . . . . . . . . : 媒体已断开连接
连接特定的 DNS 后缀 . . . . . . . : 无线局域网适配器 本地连接* 2:媒体状态. . . . . . . . . . . . : 媒体已断开连接
连接特定的 DNS 后缀 . . . . . . . : 以太网适配器 以太网:连接特定的 DNS 后缀 . . . . . . . :
本地链接 IPv6 地址. . . . . . . . : fe80::4d60:57ab:6f6b:60b1%18
IPv4 地址 . . . . . . . . . . . . : 192.168.10.22
子网掩码. . . . . . . . . . . . : 255.255.255.0
默认网关. . . . . . . . . . . . . : 192.168.10.1无线局域网适配器 WLAN:媒体状态. . . . . . . . . . . . : 媒体已断开连接
连接特定的 DNS 后缀 . . . . . . . : Process finished with exit code 0
推荐阅读
- SpringBoot调用公共模块的自定义注解失效的解决
- 如何在Mac中的文件选择框中打开系统隐藏文件夹
- thinkphp|thinkphp 3.2 如何调用第三方类库
- 单点登陆
- 操作系统|[译]从内部了解现代浏览器(1)
- 游乐园系统,助力游乐园管理
- 中国MES系统软件随工业化成长
- 推荐系统论文进阶|CTR预估 论文精读(十一)--Deep Interest Evolution Network(DIEN)
- Cesium|Cesium 粒子系统学习
- 分享!如何分分钟实现微信扫二维码调用外部浏览器打开指定页面的功能