java怎么执行外部命令?

allenzz 2001-09-19 01:09:24
java怎么执行外部命令?
...全文
111 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hexiaofeng 2001-09-19
  • 打赏
  • 举报
回复
String s = "r.exe";
Process proc = Runtime.getRuntime().exec(s);
vdragon 2001-09-19
  • 打赏
  • 举报
回复
java.lang.Runtime
exec
public Process exec(String command)
throws IOException
Executes the specified string command in a separate process.
The command argument is parsed into tokens and then executed as a command in a separate process. The token parsing is done by a StringTokenizer created by the call:

new StringTokenizer(command)

with no further modifications of the character categories. This method has exactly the same effect as exec(command, null).
Parameters:
command - a specified system command.
Returns:
a Process object for managing the subprocess.
Throws:
SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess.
ghw 2001-09-19
  • 打赏
  • 举报
回复
好多这样的贴子,自己搜索一下吧

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧