Java 8 Process - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Process class.

This code example shows how to use the following methods:destroy, waitFor
  // this should be private. 
  public void run() { 
    try { 
      sleep (msDelay);
      // bad, the timeout happened, so destroy the process 
      process.destroy();
      try { 
        process.waitFor();
      } catch (InterruptedException e) {
        WLog.log("ThreadAborterTimer timeout failure"); 
        WLog.logThrowable(e);
      } 
    } catch (InterruptedException e) {
      // good, the timer was aborted before timeout 
    } 
  } 
} 
 
6
CodeRank
This code example shows how to use the following methods:destroy, exitValue
      } 
    } catch(Exception e) {
      Log.e("NetworkLog", "Exception finishing [" + tag + "]", e);
    } 
 
    process.destroy();
    process = null;
  } 
 
  public boolean checkForExit() { 
    try { 
      exitval = process.exitValue();
      MyLog.d("ShellCommand exited: [" + tag + "] exit " + exitval);
    } catch(IllegalThreadStateException e) {
      return false; 
    } 
 
    finish(); 
    return true; 
  } 
6
CodeRank
This code example shows how to use the following methods:destroy, waitFor
  } 
 
  public int waitForExit() { 
    try { 
      if(process != null) {
        exitval = process.waitFor();
        MyLog.d("ShellCommand exited: [" + tag + "] exit " + exitval);
      } else { 
        MyLog.d("ShellCommand waitForExit: [" + tag + "] has no process");
      } 
 
      finish(); 
    } catch (InterruptedException e) {
      e.printStackTrace();
    } 
    return exitval;
  } 
 
  public boolean checkForExit() { 
    return checkForExit(false); 

5
CodeRank
This code example shows how to use the following methods:waitFor
 
    private static boolean isReachableByPing(String client) {
        try { 
            Runtime runtime = Runtime.getRuntime();
            Process mIpAddrProcess = runtime.exec("/system/bin/ping -c 1 -w 3 " + client);
            int mExitValue = mIpAddrProcess.waitFor();
            return (mExitValue == 0);
        } catch (InterruptedException e) {
            // Ignore 
        } catch (IOException e) {
            // Ignore 
        } 
        return false; 
    } 
 
    public static class ClientScanResult { 
        public String ipAddr;
        public String hwAddr;
        public String device;
        public String vendor;
4
CodeRank

Related Java 8 Process Questions & Answers:

See Code Examples for Java 8 Process Methods: