执行DOS命令并返回结果
发布时间:2021-01-09 17:45:51 所属栏目:系统 来源:网络整理
导读:public static String excuteCommand(String command){ Runtime runtime = Runtime.getRuntime(); try { Process process = runtime.exec(command); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(process.getInputStream(),C
public static String excuteCommand(String command){ Runtime runtime = Runtime.getRuntime(); try { Process process = runtime.exec(command); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream(),Charset.forName("GBK"))); StringBuffer sb = new StringBuffer(); String inline; while(null != (inline = bufferedReader.readLine())){ sb.append(inline).append("n"); } return sb.toString(); } catch (IOException e) { e.printStackTrace(); return null; } (编辑:西双版纳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |