package 常用类.System; /** * Properties 集合中都是String类型的建和值*/ import java.util.Properties; import java.util.Set; public class SystemDemo { private static final String LINE_SEPARATOR =System.getProperty("line.separator"); //获取当前操作系统换行命令代码 public static void main(String[] args) { System.out.println("Hello"+LINE_SEPARATOR+"World"); //得到系统属性,这个方法返回的是一个Properties集合,是map子类; Properties prop = System.getProperties(); //设置系统属性 System.setProperty("webdriver.chrome.driver", "C:\chrome.driver"); Set<String> nameSet = prop.stringPropertyNames();//获取键的set集合 for(String key:nameSet){ String value=prop.getProperty(key); System.out.println(key+"::"+value); } } }
package 常用类.System; import java.util.Properties; import java.util.Set; public class SystemTest { public static void main(String[] args) { demo_1(); demo_2(); demo_3(); } public static void demo_3() { final String LINE_SEPARATOR=System.getProperty("line.separator"); System.out.println("Hello"+LINE_SEPARATOR+"World"); System.setProperty("webdriver.ie.driver", "C:\IE"); } public static void demo_2() { Properties prop1=System.getProperties(); Set<String> keySet=prop1.stringPropertyNames(); for(String s1:keySet){ String value = prop1.getProperty(s1); System.out.println(s1+":"+value); } } public static void demo_1(){ //获取当前时间的毫秒值 Long l1=System.currentTimeMillis(); System.out.println(l1); } }