Class Runtimes

java.lang.Object
cn.xuanyuanli.core.util.Runtimes

public class Runtimes extends Object
运行时工具类
Author:
John Li
  • Field Details

    • AT_SYMBOL

      public static final char AT_SYMBOL
      @符号
      See Also:
    • logger

      private static final org.slf4j.Logger logger
      日志记录器
  • Constructor Details

    • Runtimes

      public Runtimes()
  • Method Details

    • execCommand

      public static Process execCommand(String[] command) throws IOException
      执行命令
      Parameters:
      command - 命令
      Returns:
      Process
      Throws:
      IOException
    • execCommandAndGetInput

      public static String execCommandAndGetInput(String[] command)
      执行命令并获得输出,编码默认为gbk。此执行将会阻塞线程,一直到子进程结束
      Parameters:
      command - 命令
      Returns:
      String
    • execCommandAndGetInput

      public static String execCommandAndGetInput(String[] command, String charset)
      执行命令并获得输出。此执行将会阻塞线程,一直到子进程结束
      Parameters:
      command - 命令
      charset - 字符集
      Returns:
      String
    • runBat

      public static Process runBat(String batPath, String batName)
      运行bat文件(仅限windows环境下使用)。此执行会打开新窗口,是没有阻塞的
      Parameters:
      batPath - 脚本所在目录
      batName - 脚本名称
      Returns:
      Process
    • getPid

      public static int getPid()
      获得java进程id
      Returns:
      java进程id
    • getRuntimeJarName

      public static String getRuntimeJarName()
      获得运行时的程序名称
      Returns:
      String
    • sleep

      public static void sleep(int millis)
      线程睡眠
      Parameters:
      millis - 米尔斯
    • runZookeeperStartBat

      public static void runZookeeperStartBat()
      运行zk启动脚步(仅限windows环境下使用)
    • getParentStackTrace

      public static List<String> getParentStackTrace(String basePackage, int maxSize)
      获得方法的父调用链
      Parameters:
      basePackage - 基本包
      maxSize - 最大大小
      Returns:
      Listinvalid input: '<'String>
      See Also:
    • getParentStackTrace

      public static List<String> getParentStackTrace(String basePackage, int maxSize, boolean skipAopProxyClass)
      获得方法的父调用链
      Parameters:
      basePackage - 基础包名
      maxSize - 最大条数
      skipAopProxyClass - 是否跳过代理类
      Returns:
      如果结果大于1,则不包含方法本身;否则包括