嗨,我正在使用此代码运行 shell 脚本。问题是我想在运行程序时传递参数“trng-java”。像这样
like java Classname trng-java
代码:
import java.io.*;
public class Test
{
public static void main(String[] args)
{
try {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(new String[]{"/bin/sh", "/tmp/test.sh", "trng-java"});
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = "";
while ((line = input.readLine()) != null) {
System.out.println(line);
}
}
catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
}
这个怎么做?