要先安装nodejs和svgo 

安装好nodejs后在cmd里面输入npm i svgo -g(liunx下直接输入)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by Administrator on 2020/3/2.
 */
public class TestTT {

    public static void main(String[] args) throws IOException, InterruptedException {
        String command = "cmd /c svgo d:/dwg/a.svg"; //windows
//        String command = " svgo /home/a.svg";//linux
//        String command = "ping baidu.com -t";
//        String command = "cmd /c node -v";
        Process process = Runtime.getRuntime().exec(command);
        BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        process.waitFor();
        System.out.println ("exit: " + process.exitValue());
        process.destroy();
    }
}

  

相关文章:

  • 2022-12-23
  • 2021-07-20
  • 2021-10-25
  • 2021-05-01
  • 2021-10-29
  • 2022-02-09
  • 2021-12-02
  • 2021-12-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-10-20
  • 2021-10-03
  • 2022-12-23
相关资源
相似解决方案