IT. Expert System.

Android Reference

Process


java.lang

Class Process



  • public abstract class Process
    extends Object
    Represents an external process. Enables writing to, reading from, destroying, and waiting for the external process, as well as querying its exit value. Use ProcessBuilder to create processes.

    The child process writes its output to two streams, out and err. These streams should be read by the parent process using getInputStream() and getErrorStream() respectively. If these streams are not read, the target process may block while it awaits buffer space. It isn't sufficient to read the streams in sequence; to avoid blocking each of the two streams must have its own reader thread. If you are not interested in differentiating the out and err streams, use redirectErrorStream(true) to merge the two streams. This simplifies your reading code and makes it easier to avoid blocking the target process.

    Running processes hold resources. When a process is no longer used, the process should be closed by calling destroy(). This will kill the process and release the resources that it holds.

    For example, to run /system/bin/ping to ping android.com:

       Process process = new ProcessBuilder()
           .command("/system/bin/ping", "android.com")
           .redirectErrorStream(true)
           .start();
       try {
         InputStream in = process.getInputStream();
         OutputStream out = process.getOutputStream();
    
         readStream(in);
    
       } finally {
         process.destroy();
       }
     
    • Constructor Summary

      Constructors
      Constructor and Description
      Process()
    • Method Summary

      Methods
      Modifier and Type Method and Description
      abstract void destroy()
      Terminates this process and closes any associated streams.
      abstract int exitValue()
      Returns the exit value of the native process represented by this object.
      abstract InputStream getErrorStream()
      Returns an input stream that is connected to the error stream (stderr) of the native process represented by this object.
      abstract InputStream getInputStream()
      Returns an input stream that is connected to the standard output stream (stdout) of the native process represented by this object.
      abstract OutputStream getOutputStream()
      Returns an output stream that is connected to the standard input stream (stdin) of the native process represented by this object.
      abstract int waitFor()
      Causes the calling thread to wait for the native process associated with this object to finish executing.
    • Constructor Detail

      • Process

        public Process()
    • Method Detail

      • destroy

        public abstract void destroy()
        Terminates this process and closes any associated streams.
      • exitValue

        public abstract int exitValue()
        Returns the exit value of the native process represented by this object. It is available only when the native process has terminated.
        Returns:
        the exit value of this process.
        Throws:
        IllegalThreadStateException - if this process has not terminated.
      • getErrorStream

        public abstract InputStream getErrorStream()
        Returns an input stream that is connected to the error stream (stderr) of the native process represented by this object.
        Returns:
        the input stream to read from the error stream associated with the native process.
      • getInputStream

        public abstract InputStream getInputStream()
        Returns an input stream that is connected to the standard output stream (stdout) of the native process represented by this object.
        Returns:
        the input stream to read from the output stream associated with the native process.
      • getOutputStream

        public abstract OutputStream getOutputStream()
        Returns an output stream that is connected to the standard input stream (stdin) of the native process represented by this object.
        Returns:
        the output stream to write to the input stream associated with the native process.
      • waitFor

        public abstract int waitFor()
                             throws InterruptedException
        Causes the calling thread to wait for the native process associated with this object to finish executing.
        Returns:
        the exit value of the native process being waited on.
        Throws:
        InterruptedException - if the calling thread is interrupted.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 958 / . Delta: 0.03316 с