Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
AFAIK,可以使用Runtime. 甚至可以通过进程获取错误代码WaitFor()。但是我怎样才能读取可执行文件的输出呢?标准输出和标准错误?
Runtime
WaitFor()
Runtime tr = Runtime.getRuntime(); try { Process p = tr.exec("c:\\a.bat"); InputStream err = p.getErrorStream(); InputStream std = p.getInputStream(); //TODO here we go! } catch (IOException e) { e.printStackTrace(); }