如何将给定程序的 return 运行时保存为整数?
How to return runtime of a given programm saved as an Integer?
我希望我的方法 getRuntime return 作业的运行时间。
public int getRuntime(int job) throws IndexOutOfBoundsException
{
Runtime run = Runtime.getRuntime();
int[] i;
i = getJobs();
if(0 < job && job < i.length )
{
int realjob = i[job];
return Runtime.getRuntime().exec(command);
}
else
{
throw new IndexOutOfBoundsException();
}
}
首先我检查了数组作业中是否有元素,以及给定作业的索引。比想要 return 这个给定作业的运行时间。
问题:当 .exec(command) 需要命令时,如何 return 给定作业的运行时间?
java 程序中只有一个运行时,这就是为什么它是静态调用 Runtime.getRuntime()。你想在这里做什么对我来说毫无意义。访问 java 中的 Runtime 用于在操作系统中执行命令。
当你用 Runtime 执行时你得到一个进程,也许这就是你真正想要的。
我希望我的方法 getRuntime return 作业的运行时间。
public int getRuntime(int job) throws IndexOutOfBoundsException
{
Runtime run = Runtime.getRuntime();
int[] i;
i = getJobs();
if(0 < job && job < i.length )
{
int realjob = i[job];
return Runtime.getRuntime().exec(command);
}
else
{
throw new IndexOutOfBoundsException();
}
}
首先我检查了数组作业中是否有元素,以及给定作业的索引。比想要 return 这个给定作业的运行时间。
问题:当 .exec(command) 需要命令时,如何 return 给定作业的运行时间?
java 程序中只有一个运行时,这就是为什么它是静态调用 Runtime.getRuntime()。你想在这里做什么对我来说毫无意义。访问 java 中的 Runtime 用于在操作系统中执行命令。 当你用 Runtime 执行时你得到一个进程,也许这就是你真正想要的。