import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class testjava { public static void main(String[] arg) { // Java调用 dos命令 String cmd = "node -v"; try { Process process = Runtime.getRuntime().exec(cmd); InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String content = br.readLine(); while (content != null) { System.out.println(content); content = br.readLine(); } } catch (IOException e) { e.printStackTrace(); } } }
效果:
原文地址:https://www.cnblogs.com/loaderman/p/11768235.html
时间: 2024-11-05 21:59:52