JAVA program How to copy a directory of files and subdirectories to another directory, how to obtain system environment variables ... __java

Source: Internet
Author: User
Tags file separator

Package test;


Import Java.io.BufferedReader;

Import java.io.IOException;

Import Java.io.InputStreamReader;


public class Test {

/**

* @param args

*/

public static void Main (string[] args) {

try {

Copy the directory and all the files and subdirectories under it

Runtime.getruntime (). EXEC ("xcopy c://aaa e://dd/s/e");


Get Windows System Environment variables

Process p = runtime.getruntime ()

. EXEC ("cmd.exe/c echo%java_home%");

BufferedReader br = new BufferedReader (new InputStreamReader p

. getInputStream ());

System.out.println (Br.readline ());


Setting Windows System Environment variables

Runtime.getruntime (). EXEC ("cmd.exe/c set aa=c://;");


/**

* Description of Key correlation value

* Java.version Java Version number

* Java.vendor java specified vendor string

* java.vendor.url Java Vendor URL

* Java.home Java installation directory

* Java.class.version Java class format version number

* Java.class.path Java Classpath

* Os.name Operating system name

* Os.arch Operating system structure

* Os.version Operating system version

* File.separator File Separator (on UNIX as "/")

* Path.separator Path Separator (on UNIX is ":")

* Line.separator line break (on UNIX is "/n")

* User.Name User account name

* User.home User Home Directory

* User.dir User's current working directory

* Wait a minute ...

*/

Get System Properties

System.out.println (System.getproperty ("Java.class.path"));

catch (IOException e) {

E.printstacktrace ();

}

}

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.