package com.anxin.ssk.util;
import java.awt.Desktop;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.anxin.ssk.common.Config;
public class CommandUtil {
private static Logger log = LoggerFactory.getLogger(CommandUtil.class);
/**
* 执行cmd命令
*
* @param command
* @throws IOException
*/
public static String executeCmd(String command) throws IOException {
log.info("Execute command : " + command);
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("cmd /c " + command);
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
String line = null;
StringBuilder build = new StringBuilder();
while ((line = br.readLine()) != null) {
Java判断应用程序启动状态并打开或关闭应用程序
最新推荐文章于 2024-09-23 23:45:42 发布
本文介绍了如何使用Java来判断应用程序的启动状态,并详细讲解了如何根据程序状态执行开启或关闭操作,涉及到的关键技术包括Java的Desktop API和进程管理。

最低0.47元/天 解锁文章
4万+

被折叠的 条评论
为什么被折叠?



