All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mountcloud.ffmepg.util.FFTerminalCreater Maven / Gradle / Ivy

package org.mountcloud.ffmepg.util;

import java.io.*;
import java.util.List;

/**
 * 命令行生成器
 * com.ugirls.ffmepg.util.terminal
 * 2018/6/11.
 *
 * @author zhanghaishan
 * @version V1.0
 */
public class FFTerminalCreater {

    private static FFTerminalCreater creater = null;

    public static FFTerminalCreater getCreater(){
        if(creater == null){
            creater = new FFTerminalCreater();
        }
        return creater;
    }

    /**
     * 获取一个命令的命令对象
     * @param cmd 命令
     * @return 命令对象
     * @throws IOException 异常
     */
    public FFTerminal getTerminal(String cmd) throws IOException {

        String[] cmds = new String[3];

        if(OSUtils.WINDOWS){
            cmds[0] = "cmd";
            cmds[1] = "/c";
        }else{
            cmds[0] = "/bin/sh";
            cmds[1] = "-c";
        }

        cmds[2] = cmd;

        FFTerminal ffTerminal = new FFTerminal( Runtime.getRuntime().exec(cmd));
        return ffTerminal;
    }

    /**
     * 获取一个命令的命令对象
     * @param cmd 命令
     * @return 命令工具
     * @throws IOException 异常
     */
    public FFTerminal getTerminal(String[] cmd) throws IOException {
        FFTerminal ffTerminal = new FFTerminal( Runtime.getRuntime().exec(cmd));
        return ffTerminal;
    }

    /**
     * 获取一个命令的命令对象
     * @param cmd 命令
     * @param params 参数
     * @return 命令对象
     * @throws IOException 异常
     */
    public FFTerminal getTerminal(String cmd, List params) throws IOException {
        String[] tempParams = new String[params.size()];
        for(int i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy