java.lang.Runtime.exec()的左膀右臂:流输入和流读取
在java.lang.Runtime.exec的使用中,我们经常会用到将重定向命令执行的输入/结果或者将错误信息读取出来.
那么,在使用过程中,我们如何正确的使用呢?
什么是java.lang.Runtime
首先我们要明确一点,什么是Java.lang.Runtime? 我们来看官方[->link<-]的描述:
" Every Java application has a single instance of class
Runtime
that allows the application to interface with the environment in which the application is running. The current runtime can be obtained from thegetRuntime
method.An application cannot create its own instance of this class. "
也就是说,Runtime是每个java-application运行时有且仅有一个的当前实例.允许Application接入当前运行环境.
我们再来看看Runtime的exec()方法: