java.lang.Object | |
↳ | java.lang.System |
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.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
err | Default error output stream. | ||||||||||
in | Default input stream. | ||||||||||
out | Default output stream. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Copies
length elements from the array src ,
starting at offset srcPos , into the array dst ,
starting at offset dstPos . | |||||||||||
Removes a specific system property.
| |||||||||||
Returns the
Console associated with this VM, or null. | |||||||||||
Returns the current time in milliseconds since January 1, 1970 00:00:00.0 UTC.
| |||||||||||
Causes the VM to stop running and the program to exit with the given exit status.
| |||||||||||
Indicates to the VM that it would be a good time to run the
garbage collector.
| |||||||||||
Returns the system properties.
| |||||||||||
Returns the value of a particular system property or
null if no
such property exists. | |||||||||||
Returns the value of a particular system property.
| |||||||||||
Returns null.
| |||||||||||
Returns the value of the environment variable with the given name, or null if no such
variable exists.
| |||||||||||
Returns an unmodifiable map of all environment variables to their values.
| |||||||||||
Returns an integer hash code for the parameter.
| |||||||||||
Returns the inherited channel from the creator of the current virtual
machine.
| |||||||||||
Returns the system's line separator.
| |||||||||||
Loads and links the dynamic library that is identified through the
specified path.
| |||||||||||
Loads and links the library with the specified name.
| |||||||||||
Returns the platform specific file name format for the shared library
named by the argument.
| |||||||||||
Returns the current timestamp of the most precise timer available on the
local system, in nanoseconds.
| |||||||||||
Provides a hint to the VM that it would be useful to attempt
to perform any outstanding object finalization.
| |||||||||||
This method was deprecated
in API level 1.
This method is unsafe.
| |||||||||||
Sets the standard error output stream to the given user defined output
stream.
| |||||||||||
Sets the standard input stream to the given user defined input stream.
| |||||||||||
Sets the standard output stream to the given user defined output stream.
| |||||||||||
Attempts to set all system properties.
| |||||||||||
Sets the value of a particular system property.
| |||||||||||
Throws
SecurityException . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Copies length
elements from the array src
,
starting at offset srcPos
, into the array dst
,
starting at offset dstPos
.
The source and destination arrays can be the same array, in which case copying is performed as if the source elements are first copied into a temporary array and then into the destination array.
src | the source array to copy the content. |
---|---|
srcPos | the starting index of the content in src . |
dst | the destination array to copy the data into. |
dstPos | the starting index for the copied content in dst . |
length | the number of elements to be copied. |
Removes a specific system property. Most system properties
are read only and cannot be cleared or modified. See setProperty(String, String)
for a
list of such properties.
null
if the property didn't exist.NullPointerException | if the argument is null . |
---|---|
IllegalArgumentException | if the argument is empty. |
Returns the Console
associated with this VM, or null.
Not all VMs will have an associated console. A console is typically only
available for programs run from the command line.
Returns the current time in milliseconds since January 1, 1970 00:00:00.0 UTC.
This method always returns UTC times, regardless of the system's time zone.
This is often called "Unix time" or "epoch time".
Use a DateFormat
instance to format this time for display to a human.
This method shouldn't be used for measuring timeouts or
other elapsed time measurements, as changing the system time can affect
the results. Use nanoTime()
for that.
Causes the VM to stop running and the program to exit with the given exit status.
If runFinalizersOnExit(boolean)
has been previously invoked with a
true
argument, then all objects will be properly
garbage-collected and finalized first.
Indicates to the VM 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.
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 value of a particular system property or null
if no
such property exists.
The following properties are always provided by the Dalvik VM and cannot be modified:
Name | Meaning | Example |
file.separator | separator | / |
java.class.path | System class path | . |
java.class.version | (Not useful on Android) | 50.0 |
java.compiler | (Not useful on Android) | Empty |
java.ext.dirs | (Not useful on Android) | Empty |
java.home | Location of the VM on the file system | /system |
java.io.tmpdir | See createTempFile(String, String) | /sdcard |
java.library.path | Search path for JNI libraries | /vendor/lib:/system/lib |
java.vendor | Human-readable VM vendor | The Android Project |
java.vendor.url | URL for VM vendor's web site | http://www.android.com/ |
java.version | (Not useful on Android) | 0 |
java.specification.version | VM libraries version | 0.9 |
java.specification.vendor | VM libraries vendor | The Android Project |
java.specification.name | VM libraries name | Dalvik Core Library |
java.vm.version | VM implementation version | 1.2.0 |
java.vm.vendor | VM implementation vendor | The Android Project |
java.vm.name | VM implementation name | Dalvik |
java.vm.specification.version | VM specification version | 0.9 |
java.vm.specification.vendor | VM specification vendor | The Android Project |
java.vm.specification.name | VM specification name | Dalvik Virtual Machine Specification |
line.separator | The system line separator | \n |
os.arch | OS architecture | armv7l |
os.name | OS (kernel) name | Linux |
os.version | OS (kernel) version | 2.6.32.9-g103d848 |
path.separator | See pathSeparator | : |
user.dir | Base of non-absolute paths | / |
user.home | (Not useful on Android) | Empty |
user.name | (Not useful on Android) | Empty |
It is an error to override anyone of these properties. Any attempt to do so will leave their values unchanged.
propertyName | the name of the system property to look up. |
---|
null
if the
property doesn't exist.
Returns the value of a particular system property. The defaultValue
will be returned if no such property has been found.
Returns null. Android does not use SecurityManager
. This method
is only provided for source compatibility.
Returns the value of the environment variable with the given name, or null if no such variable exists.
Returns an unmodifiable map of all environment variables to their values.
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
.
anObject | the object to calculate the hash code. |
---|
Returns the inherited channel from the creator of the current virtual machine.
Channel
or null
if none exists.IOException | if an I/O error occurred. |
---|
Returns the system's line separator. On Android, this is "\n"
. The value
comes from the value of the line.separator
system property when the VM
starts. Later changes to the property will not affect the value returned by this
method.
Loads and links the dynamic library that is identified through the
specified path. This method is similar to loadLibrary(String)
,
but it accepts a full path specification whereas loadLibrary
just
accepts the name of the library to load.
pathName | the path of the file to be loaded. |
---|
Loads and links the library with the specified name. The mapping of the specified library name to the full path for loading the library is implementation-dependent.
libName | the name of the library to load. |
---|
UnsatisfiedLinkError | if the library could not be loaded. |
---|
Returns the platform specific file name format for the shared library named by the argument.
userLibName | the name of the library to look up. |
---|
Returns the current timestamp of the most precise timer available on the
local system, in nanoseconds. Equivalent to Linux's CLOCK_MONOTONIC
.
This timestamp should only be used to measure a duration by comparing it
against another timestamp on the same device.
Values returned by this method do not have a defined correspondence to
wall clock times; the zero value is typically whenever the device last booted.
Use currentTimeMillis()
if you want to know what time it is.
Provides a hint to the VM that it would be useful to attempt to perform any outstanding object finalization.
This method was deprecated
in API level 1.
This method is unsafe.
Ensures that, when the VM 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.
flag | the flag determines if finalization on exit is enabled. |
---|
Sets the standard error output stream to the given user defined output stream.
newErr | the user defined output stream to set as the standard error output stream. |
---|
Sets the standard input stream to the given user defined input stream.
newIn | the user defined input stream to set as the standard input stream. |
---|
Sets the standard output stream to the given user defined output stream.
newOut | the user defined output stream to set as the standard output stream. |
---|
Attempts to set all system properties. Copies all properties from
p
and discards system properties that are read only and cannot
be modified. See setProperty(String, String)
for a list of such properties.
Sets the value of a particular system property. Most system properties
are read only and cannot be cleared or modified. See setProperty(String, String)
for a
list of such properties.
null
if the property
didn't exist.
Throws SecurityException
.
Security managers do not provide a secure environment for
executing untrusted code and are unsupported on Android. Untrusted code
cannot be safely isolated within a single VM on Android, so this method
always throws a SecurityException
.
sm | a security manager |
---|
SecurityException | always |
---|