就可以运行路径指衫为D:\\Program Files\\vmware.exe的外部指竖程序了
import java.io.*import java.lang.*
import java.nio.charset.*
public class Rt
{
public static void main(String[] args) throws Exception
{
if( args.length == 0 ) {
System.out.println("用法竖唤: java Rt <目标EXE><提供给EXE的参数尺或...>")
return
}
Runtime rt = Runtime.getRuntime()
ProcessBuilder pb = new ProcessBuilder(args)
Process p = pb.start()
p.waitFor()
int exitCode = p.exitValue()
System.out.println("exitCode = " + exitCode)
InputStream resultStream = p.getInputStream()
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()
int size, SIZE = 4096
byte[] buffer = new byte[SIZE]
while( (size = resultStream.read(buffer)) != -1 ) {
outputStream.write(buffer, 0, size)
}
byte[] bytes = outputStream.toByteArray()
outputStream.close()
String str = new String(bytes)
System.out.println(str)
}
/*
#include <stdio.h>
int main(int argc, char *argv[])
{
int i = 0
printf("argc = %d\陵纤伍n", argc)
for(i = 0i <argci ++)
printf("argv[%d] = %s\n", i, argv[i])
return 0
}
*/
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)