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中文網其他相關文章!