6.2.1 The System class 

Previous Index Next 


This class provides several useful methods. These include access to the console IO streams, a fast way of copying arrays, access to information about the Java VM and the ability to terminate the currently running application. These methods are detailed below. For a full list look at the Java API documentation.
 
 
err This attribute holds a reference to the console's error output stream.
in This attribute holds a reference to the console's input stream.
out This attribute holds a reference to the console's output stream.
arraycopy This method copies the contents of one array to another.
currentTimeMillis This method returns the system time as the number of milliseconds since midnight, January 1, 1970 UTC. 
exit This terminates the Java VM. It takes a single integer as a parameter. This value is returned as an exit code when the Java VM terminates.
gc This method triggers the garbage collection routines in the Java VM. The Java VM will clean up all the unused objects when this method is called.
getProperty This returns the value of the specified system property. The properties available are:
  • java.version - Java version number 
  • java.vendor - Java vendor-specific string 
  • java.vendor.url - Java vendor URL 
  • java.home - Java installation directory 
  • java.class.version - Java class format version number 
  • java.class.path - Java class path 
  • os.name - Operating system name 
  • os.arch - Operating system architecture 
  • os.version - Operating system version 
  • file.separator - File separator ("/" on UNIX) 
  • path.separator - Path separator (":" on UNIX) 
  • line.separator - Line separator ("\n" on UNIX) 
  • user.name - User's account name 
  • user.home - User's home directory 
  • user.dir - User's current working directory 



Source 1