java.lang
public
final
class
java.lang.System
Class System provides a standard place for programs to find system related
information. All System API is static.
Summary
Constants
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
public
static
final
PrintStream
err
Default error output stream
public
static
final
InputStream
in
Default input stream
public
static
final
PrintStream
out
Default output stream
Public Methods
public
static
void
arraycopy(Object array1, int start1, Object array2, int start2, int length)
Copies the contents of
array1
starting at offset
start1
into
array2
starting at offset
start2
for
length
elements.
Parameters
array1
| the array to copy out of |
start1
| the starting index in array1 |
array2
| the array to copy into |
start2
| the starting index in array2 |
length
| the number of elements in the array to copy
|
public
static
String
clearProperty(String key)
Removes the system property for the specified key.
Please see the Java SE API documentation for further
information on this method.
Parameters
key
| the system property to be removed. |
Returns
- previous value or null if no value existed
public
static
long
currentTimeMillis()
Returns the current time expressed as milliseconds since the time
00:00:00 UTC on January 1, 1970.
Returns
- the time in milliseconds.
public
static
void
exit(int code)
Causes the virtual machine to stop running, and the program to exit. If
runFinalizersOnExit(true) has been invoked, then all finalizers will be
run first.
public
static
void
gc()
Indicate to the virtual machine that it would be a good time to collect
available memory. Note that, this is a hint only.
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.
Security managers should restrict access to this API if possible.
public
static
String
getProperty(String prop, String defaultValue)
Returns the value of a particular system property. If no such property is
found, returns the defaultValue.
Parameters
prop
| the system property to look up |
defaultValue
| return value if system property is not found |
Returns
- the value of the specified system property, or defaultValue if
the property doesn't exist
public
static
String
getProperty(String prop)
Returns the value of a particular system property. Returns 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 system property to look up |
Returns
- the value of the specified system property, or null if the
property doesn't exist
public
static
SecurityManager
getSecurityManager()
Returns the active security manager.
Returns
- the system security manager object.
public
static
String
getenv(String var)
Returns an environment variable.
Parameters
var
| the name of the environment variable |
Returns
- the value of the specified environment variable
Returns all environment variables.
Returns
- A Map of all environment variables.
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 java.lang.Object.hashCode(),
whether or not the object's class has overridden hashCode(). The hash
code for null is 0.
Returns
- the hash code for the object
public
static
Channel
inheritedChannel()
Returns the inherited channel from the system-wide provider.
public
static
void
load(String pathName)
Loads the specified file as a dynamic library.
Parameters
pathName
| the path of the file to be loaded
|
public
static
void
loadLibrary(String libName)
Loads and links the library specified by the argument.
Parameters
libName
| the name of the library to load |
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
public
static
long
nanoTime()
Returns the most precise time measurement in nanoseconds that's
available.
Returns
- The current time in nanoseconds.
public
static
void
runFinalization()
Provides a hint to the virtual machine that it would be useful to attempt
to perform any outstanding object finalizations.
public
static
void
runFinalizersOnExit(boolean flag)
This method is deprecated.
This method is unsafe.
Ensure 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
| true means finalize all on exit. |
public
static
void
setErr(PrintStream newErr)
Sets the value of the static slot "err" in the receiver to the passed in
argument.
Parameters
newErr
| the new value for err.
|
public
static
void
setIn(InputStream newIn)
Sets the value of the static slot "in" in the receiver to the passed in
argument.
Parameters
newIn
| the new value for in.
|
public
static
void
setOut(PrintStream newOut)
Sets the value of the static slot "out" in the receiver to the passed in
argument.
Parameters
newOut
| the new value for out.
|
public
static
void
setProperties(Properties p)
Returns the system properties. Note that the object which is passed in
not copied, so that subsequent changes made to the object will be
reflected in calls to getProperty and getProperties.
Security managers should restrict access to this API if possible.
public
static
String
setProperty(String prop, String value)
Sets the value of a particular system property.
Parameters
prop
| the system property to change |
value
| the value to associate with prop |
Returns
- the old value of the property, or null
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 so 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.
|