要先安装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();
}
}
浙公网安备 33010602011771号