|
Qizx/open API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.axyana.qizxopen.util.PlatformUtil
A collection of utility functions (static methods) returning information which is platform dependent.
Field Summary | |
static int |
GENERIC_UNIX
|
static boolean |
IS_GENERIC_UNIX
|
static boolean |
IS_MAC_OS
|
static boolean |
IS_WINDOWS
|
static int |
MAC_OS
|
static int |
PLATFORM
|
static int |
WINDOWS
|
Constructor Summary | |
PlatformUtil()
|
Method Summary | |
static int |
captureOutput(java.lang.Process process,
java.lang.String[] capture)
Captures output of specified newly started process (see shellStart(String) ). |
static java.lang.String |
commandSeparator()
Returns the command separator of the standard shell of the platform. |
static java.util.HashMap |
getEnvironment()
Returns all environment variables in a HashMap .
|
static void |
getEnvironment(java.util.HashMap env)
Adds all environment variables to specified HashMap .
|
static java.lang.String |
homeDir()
Returns the name of the home directory of current user. |
static java.lang.String |
rcFileName(java.lang.String appName)
Returns the name of the user preference file associated to the specified application. |
static int |
shellExec(java.lang.String command)
Executes a command using the standard shell of the platform. |
static int |
shellExec(java.lang.String command,
boolean verbose)
Executes a command using the standard shell of the platform. |
static int |
shellExec(java.lang.String command,
java.lang.String[] capture)
Executes a command using the standard shell of the platform, capturing output to System.out and System.err . |
static java.lang.Process |
shellStart(java.lang.String command)
Executes a command using the standard shell of the platform. |
static java.lang.String |
tmpDir()
Returns the name of directory where temporary files can be created safely. |
static java.lang.String |
tmpFileName()
Returns the name of a temporary file ending with extension ".tmp". |
static java.lang.String |
tmpFileName(java.lang.String extension)
Returns the name of a temporary file ending with the specified extension. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int GENERIC_UNIX
public static final int WINDOWS
public static final int MAC_OS
public static final int PLATFORM
public static final boolean IS_GENERIC_UNIX
public static final boolean IS_WINDOWS
public static final boolean IS_MAC_OS
Constructor Detail |
public PlatformUtil()
Method Detail |
public static java.lang.String homeDir()
null
if the candidate directory found by this function
does not exist or is not a directory.public static java.lang.String rcFileName(java.lang.String appName)
Note that RC means Runtime Configuration.
appName
- the application name
null
if
the user HOME directory is unknownhomeDir()
public static java.lang.String tmpFileName()
tmpDir()
.
public static java.lang.String tmpFileName(java.lang.String extension)
tmpDir()
.
extension
- the desired extension for the file name; if a dot is
required, add it at the start of extension
public static java.lang.String tmpDir()
Under Windows, the system property TMP or TEMP, if set to an existing directory, may be used to force the value returned by this function.
Under Unix, this function always returns "/tmp".
null
if the
candidate directory found by this function does not exist or is not a
directory.public static java.lang.String commandSeparator()
public static java.lang.Process shellStart(java.lang.String command) throws java.io.IOException
shellExec(String)
, does not wait until the command is completed.
command
- the shell command to be executed
java.io.IOException
- if an I/O error occurspublic static int shellExec(java.lang.String command) throws java.io.IOException, java.lang.InterruptedException
command
- the shell command to be executed
java.io.IOException
- if an I/O error occurs
java.lang.InterruptedException
- if the current thread is interrupted by
another thread while it is waiting the completion of the shell commandpublic static int shellExec(java.lang.String command, boolean verbose) throws java.io.IOException, java.lang.InterruptedException
command
- the shell command to be executedverbose
- if true, the shell command output on
System.out
and System.err
is echoed; if
false, this output is discarded
java.io.IOException
- if an I/O error occurs
java.lang.InterruptedException
- if the current thread is interrupted by
another thread while it is waiting the completion of the shell commandpublic static int shellExec(java.lang.String command, java.lang.String[] capture) throws java.io.IOException, java.lang.InterruptedException
System.out
and System.err
.
command
- the shell command to be executedcapture
- output to System.out
is captured and saved
to capture[0]
and output to System.err
is
captured and saved to capture[1]
.
java.io.IOException
- if an I/O error occurs
java.lang.InterruptedException
- if the current thread is interrupted by
another thread while it is waiting the completion of the shell commandpublic static int captureOutput(java.lang.Process process, java.lang.String[] capture) throws java.lang.InterruptedException
shellStart(String)
).
process
- newly started processcapture
- output to System.out
is captured and saved
to capture[0]
and output to System.err
is
captured and saved to capture[1]
.
java.lang.InterruptedException
- if the current thread is interrupted by
another thread while it is waiting the completion of the processpublic static java.util.HashMap getEnvironment()
HashMap
.
entrySet().iterator()
can be used to enumerate
Map.Entry
where the key is (case-sensitive) name of the
environment variable and the value is the value of the environment
variable.
public static void getEnvironment(java.util.HashMap env)
HashMap
.
entrySet().iterator()
can be used to enumerate
Map.Entry
where the key is (case-sensitive) name of the
environment variable and the value is the value of the environment
variable.
|
© 2005 Axyana Software | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |