?? propmap.java
字號:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.wwr.login;import com.wwr.commons.ResourceManager;import java.util.HashMap;import java.util.Map;/** * * @author Administrator */public class PropMap { Map<String, Object> map; public Map<String, Object> getMap() { try { // Properties prop = new Properties(); String usernames = ""; String passwords = ""; //FileInputStream fin = new FileInputStream(f); // prop.load(new FileInputStream("D:\\NetBeansProjects\\cmsProperties.properties")); usernames = ResourceManager.getString("UserNames");//prop.getProperty("UserNames"); passwords = ResourceManager.getString("Passwords");//prop.getProperty("Passwords");// System.out.println(usernames);// System.out.println(passwords); String[] UnameArr = usernames.split(","); String[] PassArr = passwords.split(","); map = new HashMap<String, Object>(); // if (UnameArr.length != PassArr.length || usernames == null || passwords == null) { // System.out.println("Error in UserNames in the property file "); for (int i = 0; i < UnameArr.length; i++) { // System.out.println(UnameArr[i]+"###"+PassArr[i]); map.put(UnameArr[i], PassArr[i]); } // }// System.out.println("Retrieving values from hashmap:");// Iterator itr = map.entrySet().iterator();// while (itr.hasNext()) {// System.out.println(itr.next());// // /// searching for a key in the map ... // // }// // } // if(map.containsKey("wwr")){// System.out.println("keyfound ");// String val=(String)map.get("wwr");// System.out.println("the value for the key is "+val+"");// } } catch (Exception ex) { ex.printStackTrace(); } return map; } /* public void getProp() { map = new HashMap<String, Object>(); try { URL url = (URL) getClass().getResource("\\ApplicationResource.properties"); System.out.print("in get Resource"); File f = null; try { System.out.println(url.toString()); f = new File(url.toURI()); } catch (URISyntaxException ex) { ex.printStackTrace(); System.out.println("Error reading the Property File"); } if (f.exists()) { Properties prop = new Properties(); FileInputStream fin = new FileInputStream(f); prop.load(fin); usernames = prop.getProperty("UserNames"); passwords = prop.getProperty("Passwords"); System.out.print(usernames); System.out.print(passwords); } } catch (Exception ex) { ex.printStackTrace(); System.out.print("unable to find the resoucrce"); } buildMap(usernames, passwords); } */ public void buildMap() { } public static void main(String args[]) { new PropMap().getMap(); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -