Java 9 通过添加新方法改进了 Process 类,还提供了新接口:ProcessHandle 和 ProcessHandle.Info 来获取有关进程及其信息的所有详细信息。
下面是 Java 9 中添加到 Process 的新方法列表
public class ProcessTest { public static void main(String args[]) { <strong> ProcessHandle </strong>processHandle = ProcessHandle.current(); <strong> ProcessHandle.Info</strong> processInfo = processHandle.info(); System.out.println(processHandle.<strong>pid()</strong>); System.out.println(processHandle.<strong>parent()</strong>); System.out.println(processInfo.<strong>arguments()</strong>.<strong>isPresent()</strong>); System.out.println(processInfo.<strong>command()</strong>.<strong>isPresent()</strong>); System.out.println(processInfo.<strong>command().get().contains</strong>("tutorialspoint")); System.out.println(processInfo.<strong>startInstant().isPresent()</strong>); } }
<strong>4892 Optional[7788] false true false true</strong>
以上是在Java 9中,Process API新增了哪些新的方法?的详细内容。更多信息请关注PHP中文网其他相关文章!