001package cn.mybatis.mp.generator.util;
002
003import java.io.IOException;
004import java.text.MessageFormat;
005import java.util.Objects;
006
007public class RuntimeUtils {
008
009    /**
010     * 打开指定输出文件目录
011     *
012     * @param path 输出文件目录
013     */
014    public static void openDir(String path) {
015        String osName = System.getProperty("os.name");
016        if (Objects.nonNull(osName)) {
017            try {
018                if (osName.contains("Mac")) {
019                    Runtime.getRuntime().exec("open " + path);
020                } else if (osName.contains("Windows")) {
021                    Runtime.getRuntime().exec(MessageFormat.format("cmd /c start \"\" \"{0}\"", path));
022                }
023            } catch (IOException e) {
024                throw new RuntimeException(e);
025            }
026        }
027    }
028}