java Properties类得到当前的系统属性

详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt218

package com.shi.simpleUtil;

import java.util.Properties;

/**

 * 得到系统的一些属性

 * @author grefr

 */

public class PropertiesDemo {

       public static void main(String[] args) {

             Properties initProp = new Properties(System.getProperties());  

         System.out.println("file.encoding----->:" +initProp.getProperty("file.encoding"));  

         System.out.println("user.language----->:" +initProp.getProperty("user.language"));

         System.out.println("user.dir----->:" +initProp.getProperty("user.dir"));

         //得到操作系统相关属性

         System.out.println( "OS name----->"+System.getProperty( "os.name"));

         System. out.println("OS arch----->"+System.getProperty("os.arch" ));

         System. out.println("OS version---->"+System.getProperty("os.version" )); 

         //得到编译后的class文件的路径

         System.out.println(System. getProperty( "java.class.path" ));

          //得到当前系统的换行符

         System.getProperty("line.separator");

      //段落分隔符 (;)

      System.getProperty("path.separator")

      }

}

原文地址:https://www.cnblogs.com/grefr/p/6094879.html