
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中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号