当前位置 : 主页 > 编程语言 > java >

CS-ExeplorerUtil

来源:互联网 收集:自由互联 发布时间:2021-06-28
gistfile1.txt package cn.huawei.com.CompressedSeacher.util;import java.io.IOException;/** * * * @author l00358914 */public class ExeplorerUtil { private static final ExeplorerUtil instance = new ExeplorerUtil(); private ExeplorerUtil() { }
gistfile1.txt
package cn.huawei.com.CompressedSeacher.util;
import java.io.IOException;

/**
 *
 *
 * @author l00358914
 */
public class ExeplorerUtil {
    private static final ExeplorerUtil instance = new ExeplorerUtil();
    private ExeplorerUtil() {
    }
    public static ExeplorerUtil getInstance() {
        return instance;
    }
    public static void execOpenFileLocation(String des) {
        if (des == null) {
            return;
        }
        String command = "explorer.exe " + des;
        try {
            Runtime.getRuntime().exec(command);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /**
     * @param path
     */
    public static void openJdiskReport() {
        String os = System.getProperties().getProperty("os.name");
        String command = null;
        if (os.contains("windows") || os.contains("Windows")) {
            command = "cmd /k start java -Xmx512m -jar  external/jdiskreport-1.4.1.jar";
            System.out.println("Windows :Invoking " + command);
        } else {
            System.out.println(System.getProperties().getProperty("user.dir"));
            String workpath = System.getProperties().getProperty("user.dir");
            StringBuffer sb = new StringBuffer();
            sb.append(" java -jar ").append(workpath).append("/external/jdiskreport-1.4.1.jar");
            command = sb.toString().trim();
            System.out.println("Linux :Invoking " + sb.toString().trim());
        }
        try {
            Runtime.getRuntime().exec(command);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /**
     * @param args
     */
    public static void main(String[] args) {
        // ExeplorerUtil.getInstance().execOpenFileLocation("c:\\");
        ExeplorerUtil.getInstance().openJdiskReport();
    }
}
上一篇:CS-FileUtils
下一篇:CS-DecompressJar
网友评论