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

  1. 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

  1. execForStr - Executes a system command and returns a string.
  2. 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.