System class

 

            Some methods below:  getProperty(...),   arrayCopy(...)

 

 

   This class creates the System.in, System.out, and System.err streams.

 

 

 

String  getProperty(...)  method 

 

   System.getProperty(“user.dir”) returns the current directory.

 

   Other property keys obtainable are:

 

java.version                       Java Runtime Environment version

java.vendor                        Java Runtime Environment vendor

java.vendor.url                   Java vendor URL

java.home                          Java installation directory

java.vm.specification.version   Java Virtual Machine specification version

java.vm.specification.vendor    Java Virtual Machine specification vendor

java.vm.specification.name  Java Virtual Machine specification name

java.vm.version                  Java Virtual Machine implementation version

java.vm.vendor                  Java Virtual Machine implementation vendor

java.vm.name                    Java Virtual Machine implementation name

java.specification.version     Java Runtime Environment specification version

java.specification.vendor     Java Runtime Environment specification vendor

java.specification.name       Java Runtime Environment specification name

java.class.version               Java class format version number

java.class.path                   Java class path

java.ext.dirs                       Path of extension directory or directories

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

 

 

void  arrayCopy( src[ ], srcIndex, dst[ ], dstIndex, len )  method

 

   Copies a len number of elements from the source array, beginning at the srcIndex position, to the dstIndex position of the destination array.

 

   This snippet copies the three elements  1 2 3  from the first array, which are located at index zero, into the second array, to reside in place of the second array’s e f g, which are located starting at index 4.

 

String[ ] a1 = {"1","2","3","4","5","6","7","8","9"};

String[ ] a2 = {"a","b","c","d","e","f","g","h","i" };

 

System.arraycopy(a1, 0, a2, 4, 3 );

 

List aList = Arrays.asList(a1) ;

System.out.println(aList);

List bList = Arrays.asList(a2) ;

System.out.println(bList);

 

   This code shifts all the elements of the array to the right by two positions, printing  a b a b c d e f g.

Notice how the first two shifted positions retain their original values, and how the shifted-out positions on the far right simply lose their old values.  The original array length is not changed.  i.e.

 

String[ ] a2 = {"a","b","c","d","e","f","g","h","i" };

System.out.println(a2.length);

System.arraycopy(a2, 0, a2, 2, a2.length-2 );

List bList = Arrays.asList(a2) ;

System.out.println(bList);