Build 1.1_r1 (from source)

java.lang
Class System

java.lang.Object
  extended by java.lang.System

public final class System
extends Object

Provides access to system-related information and resources including standard input and output. Enables clients to dynamically load native libraries. All methods of this class are accessed in a static way and the class itself can not be instantiated.

Since:
Android 1.0
See Also:
Runtime

Field Summary
static PrintStream err
          Default error output stream.
static InputStream in
          Default input stream.
static PrintStream out
          Default output stream.
 
Method Summary
static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
          Copies the number of length elements of the Array src starting at the offset srcPos into the Array dest at the position destPos.
static String clearProperty(String key)
          Removes a specific system property.
static long currentTimeMillis()
          Returns the current system time in milliseconds since January 1, 1970 00:00:00 UTC.
static void exit(int code)
          Causes the virtual machine to stop running and the program to exit.
static void gc()
          Indicates to the virtual machine that it would be a good time to run the garbage collector.
static Map<String,String> getenv()
          Returns an unmodifiable map of all available environment variables.
static String getenv(String name)
          Returns the value of the environment variable with the given name var.
static Properties getProperties()
          Returns the system properties.
static String getProperty(String prop)
          Returns the value of a particular system property or null if no such property exists.
static String getProperty(String prop, String defaultValue)
          Returns the value of a particular system property.
static SecurityManager getSecurityManager()
          Returns the active security manager.
static int identityHashCode(Object anObject)
          Returns an integer hash code for the parameter.
static Channel inheritedChannel()
          Returns the inherited channel from the creator of the current virtual machine.
(package private) static Properties internalGetProperties()
          Returns the system properties without any security checks.
static void load(String pathName)
          Loads the specified file as a dynamic library.
static void loadLibrary(String libName)
          Loads and links the shared library with the given name libName.
static String mapLibraryName(String userLibName)
          Returns the platform specific file name format for the shared library named by the argument.
static long nanoTime()
          Returns the current timestamp of the most precise timer available on the local system.
static void runFinalization()
          Provides a hint to the virtual machine that it would be useful to attempt to perform any outstanding object finalizations.
static void runFinalizersOnExit(boolean flag)
          Deprecated. this method is unsafe.
static void setErr(PrintStream newErr)
          Sets the standard error output stream to the given user defined output stream.
static void setIn(InputStream newIn)
          Sets the standard input stream to the given user defined input stream.
static void setOut(PrintStream newOut)
          Sets the standard output stream to the given user defined output stream.
static void setProperties(Properties p)
          Sets all system properties.
static String setProperty(String prop, String value)
          Sets the value of a particular system property.
static void setSecurityManager(SecurityManager sm)
          Sets the active security manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

public static final InputStream in
Default input stream.

Since:
Android 1.0

out

public static final PrintStream out
Default output stream.

Since:
Android 1.0

err

public static final PrintStream err
Default error output stream.

Since:
Android 1.0
Method Detail

setIn

public static void setIn(InputStream newIn)
Sets the standard input stream to the given user defined input stream.

Parameters:
newIn - the user defined input stream to set as the standard input stream.
Throws:
SecurityException - if a SecurityManager is installed and its checkPermission() method does not allow the change of the stream.
Since:
Android 1.0

setOut

public static void setOut(PrintStream newOut)
Sets the standard output stream to the given user defined output stream.

Parameters:
newOut - the user defined output stream to set as the standard output stream.
Throws:
SecurityException - if a SecurityManager is installed and its checkPermission() method does not allow the change of the stream.
Since:
Android 1.0

setErr

public static void setErr(PrintStream newErr)
Sets the standard error output stream to the given user defined output stream.

Parameters:
newErr - the user defined output stream to set as the standard error output stream.
Throws:
SecurityException - if a SecurityManager is installed and its checkPermission() method does not allow the change of the stream.
Since:
Android 1.0

arraycopy

public static void arraycopy(Object src,
                             int srcPos,
                             Object dest,
                             int destPos,
                             int length)
Copies the number of length elements of the Array src starting at the offset srcPos into the Array dest at the position destPos.

Parameters:
src - the source array to copy the content.
srcPos - the starting index of the content in src.
dest - the destination array to copy the data into.
destPos - the starting index for the copied content in dest.
length - the number of elements of the array1 content they have to be copied.
Since:
Android 1.0

currentTimeMillis

public static long currentTimeMillis()
Returns the current system time in milliseconds since January 1, 1970 00:00:00 UTC. This method shouldn't be used for measuring timeouts or other elapsed time measurements, as changing the system time can affect the results.

Returns:
the local system time in milliseconds.
Since:
Android 1.0

nanoTime

public static long nanoTime()
Returns the current timestamp of the most precise timer available on the local system. This timestamp can only be used to measure an elapsed period by comparing it against another timestamp. It cannot be used as a very exact system time expression.

Returns:
the current timestamp in nanoseconds.
Since:
Android 1.0

exit

public static void exit(int code)
Causes the virtual machine to stop running and the program to exit. If runFinalizersOnExit(boolean) has been previously invoked with a true argument, then all all objects will be properly garbage-collected and finalized first.

Parameters:
code - the return code.
Throws:
SecurityException - if the running thread has not enough permission to exit the virtual machine.
Since:
Android 1.0
See Also:
SecurityManager.checkExit(int)

gc

public static void gc()
Indicates to the virtual machine that it would be a good time to run the garbage collector. Note that this is a hint only. There is no guarantee that the garbage collector will actually be run.

Since:
Android 1.0

getenv

public static String getenv(String name)
Returns the value of the environment variable with the given name var.

Parameters:
name - the name of the environment variable.
Returns:
the value of the specified environment variable or null if no variable exists with the given name.
Throws:
SecurityException - if a SecurityManager is installed and its checkPermission() method does not allow the querying of single environment variables.
Since:
Android 1.0

getenv

public static Map<String,String> getenv()
Returns an unmodifiable map of all available environment variables.

Returns:
the map representing all environment variables.
Throws:
SecurityException - if a SecurityManager is installed and its checkPermission() method does not allow the querying of all environment variables.
Since:
Android 1.0

inheritedChannel

public static Channel inheritedChannel()
                                throws IOException
Returns the inherited channel from the creator of the current virtual machine.

Returns:
the inherited Channel or null if none exists.
Throws:
IOException - if an I/O error occurred.
Since:
Android 1.0
See Also:
SelectorProvider, SelectorProvider.inheritedChannel()

getProperties

public static Properties getProperties()
Returns the system properties. Note that this is not a copy, so that changes made to the returned Properties object will be reflected in subsequent calls to getProperty and getProperties.

Returns:
the system properties.
Throws:
SecurityException - if a SecurityManager is installed and its checkPropertiesAccess() method does not allow the operation.
Since:
Android 1.0

internalGetProperties

static Properties internalGetProperties()
Returns the system properties without any security checks. This is used for access from within java.lang.

Returns:
the system properties

getProperty

public static String getProperty(String prop)
Returns the value of a particular system property or null if no such property exists.

The properties currently provided by the virtual machine are:

        java.vendor.url
        java.class.path
        user.home
        java.class.version
        os.version
        java.vendor
        user.dir
        user.timezone
        path.separator
        os.name
        os.arch
        line.separator
        file.separator
        user.name
        java.version
        java.home
 

Parameters:
prop - the name of the system property to look up.
Returns:
the value of the specified system property or null if the property doesn't exist.
Throws:
SecurityException - if a SecurityManager is installed and its checkPropertyAccess() method does not allow the operation.
Since:
Android 1.0

getProperty

public static String getProperty(String prop,
                                 String defaultValue)
Returns the value of a particular system property. The defaultValue will be returned if no such property has been found.

Parameters:
prop - the name of the system property to look up.
defaultValue - the return value if the system property with the given name does not exist.
Returns:
the value of the specified system property or the defaultValue if the property does not exist.
Throws:
SecurityException - if a SecurityManager is installed and its checkPropertyAccess() method does not allow the operation.
Since:
Android 1.0

setProperty

public static String setProperty(String prop,
                                 String value)
Sets the value of a particular system property.

Parameters:
prop - the name of the system property to be changed.
value - the value to associate with the given property prop.
Returns:
the old value of the property or null if the property didn't exist.
Throws:
SecurityException - if a security manager exists and write access to the specified property is not allowed.
Since:
Android 1.0

clearProperty

public static String clearProperty(String key)
Removes a specific system property.

Parameters:
key - the name of the system property to be removed.
Returns:
the property value or null if the property didn't exist.
Throws:
NullPointerException - if the argument key is null.
IllegalArgumentException - if the argument key is empty.
SecurityException - if a security manager exists and write access to the specified property is not allowed.
Since:
Android 1.0

getSecurityManager

public static SecurityManager getSecurityManager()
Returns the active security manager.

Returns:
the system security manager object.
Since:
Android 1.0

identityHashCode

public static int identityHashCode(Object anObject)
Returns an integer hash code for the parameter. The hash code returned is the same one that would be returned by the method java.lang.Object.hashCode(), whether or not the object's class has overridden hashCode(). The hash code for null is 0.

Parameters:
anObject - the object to calculate the hash code.
Returns:
the hash code for the given object.
Since:
Android 1.0
See Also:
Object.hashCode()

load

public static void load(String pathName)
Loads the specified file as a dynamic library.

Parameters:
pathName - the path of the file to be loaded.
Throws:
SecurityException - if the library was not allowed to be loaded.
Since:
Android 1.0

loadLibrary

public static void loadLibrary(String libName)
Loads and links the shared library with the given name libName. The file will be searched in the default directory for shared libraries of the local system.

Parameters:
libName - the name of the library to load.
Throws:
UnsatisfiedLinkError - if the library could not be loaded.
SecurityException - if the library was not allowed to be loaded.
Since:
Android 1.0

runFinalization

public static void runFinalization()
Provides a hint to the virtual machine that it would be useful to attempt to perform any outstanding object finalizations.

Since:
Android 1.0

runFinalizersOnExit

@Deprecated
public static void runFinalizersOnExit(boolean flag)
Deprecated. this method is unsafe.

Ensures that, when the virtual machine is about to exit, all objects are finalized. Note that all finalization which occurs when the system is exiting is performed after all running threads have been terminated.

Parameters:
flag - the flag determines if finalization on exit is enabled.
Since:
Android 1.0

setProperties

public static void setProperties(Properties p)
Sets all system properties.

Parameters:
p - the new system property.
Throws:
SecurityException - if a SecurityManager is installed and its checkPropertiesAccess() method does not allow the operation.
Since:
Android 1.0

setSecurityManager

public static void setSecurityManager(SecurityManager sm)
Sets the active security manager. Note that once the security manager has been set, it can not be changed. Attempts to do that will cause a security exception.

Parameters:
sm - the new security manager.
Throws:
SecurityException - if the security manager has already been set and if its checkPermission method does not allow to redefine the security manager.
Since:
Android 1.0

mapLibraryName

public static String mapLibraryName(String userLibName)
Returns the platform specific file name format for the shared library named by the argument.

Parameters:
userLibName - the name of the library to look up.
Returns:
the platform specific filename for the library.
Since:
Android 1.0

Build 1.1_r1 (from source)

Please submit a feedback, bug or feature