RuntimeUtil
Introduction
In the Java world, if you want to interact with other languages, handle interface calls, or JNI, it is done through native command-line invocation. Hutool encapsulates the JDK’s Process class for executing command-line commands (cmd on Windows and shell commands on Linux).
Methods
Basic Method
exec
- Executes a command-line command and returns a Process object. The Process object can be used to read the returned content stream after executing the command.
Convenience Methods
execForStr
- Executes a system command and returns a string.execForLines
- Executes a system command and returns a list of lines.
Usage
String str = RuntimeUtil.execForStr("ipconfig");
Executing this command will retrieve network card information on Windows.