List of usage examples for java.util HashMap put
public V put(K key, V value)
From source file:zz.pseas.ghost.login.taobao.LogInTaobao.java
@SuppressWarnings("unused") public static void main(String[] args) throws Exception { String tbuserNmae = "TBname"; String tbpassWord = "TBpasssword"; String url = "https://login.taobao.com/member/login.jhtml"; WebDriver ie = BrowserFactory.getIE(); ie.get(url);//from ww w.jav a 2 s . c o m Thread.sleep(5000L); Set<Cookie> cookies = ie.manage().getCookies(); CookieStore store = DownloadUtil.convertToCookieStore(cookies); GhostClient client = new GhostClient("utf-8", store); String html = ie.getPageSource(); String pbk = Jsoup.parse(html).select("input#J_PBK").attr("value"); String pwd1 = RsaUtil.enCode(pbk, "10001", tbuserNmae); HashMap<String, String> map = new HashMap<String, String>(); map.put("TPL_username", tbuserNmae); map.put("TPL_password", tbpassWord); map.put("fc", "default"); map.put("from", "tb"); map.put("gvfdcname", "10"); map.put("keyLogin", "false"); map.put("loginASR", "1"); map.put("loginASRSuc", "1"); map.put("loginType", "3"); map.put("loginsite", "0"); map.put("naviVer", "firefox|47"); String ncoToken = Jsoup.parse(html).select("input#J_NcoToken").attr("value"); map.put("ncoToken", ncoToken); map.put("newMini", "false"); map.put("newMini2", "false"); map.put("newlogin", "0"); map.put("osVer", "windows|6.1"); map.put("oslanguage", "zh-cn"); map.put("qrLogin", "true"); map.put("slideCodeShow", "false"); map.put("sr", "1920*1080"); String ua = Jsoup.parse(html).select("input#UA_InputId").attr("value"); //map.put("ua", ua); String umToken = Jsoup.parse(html).select("input[name=um_token]").attr("value"); map.put("um_token", umToken); // TODO get um_token String ans = client.post("https://login.taobao.com/member/login.jhtml", map); System.out.println(ans); }
From source file:Main.java
public static void main(String args[]) { // create two hash maps HashMap<Integer, String> newmap1 = new HashMap<Integer, String>(); HashMap<Integer, String> newmap2 = new HashMap<Integer, String>(); // populate hash map newmap1.put(1, "tutorials"); newmap1.put(2, "from"); newmap1.put(3, "java2s.com"); // clone 1st map newmap2 = (HashMap) newmap1.clone(); System.out.println("1st Map: " + newmap1); System.out.println("Cloned 2nd Map: " + newmap2); }
From source file:Main.java
public static void main(String[] args) { File workingDirectory = new File("C:" + File.separator + "Invoices"); File template = new File(workingDirectory.getAbsolutePath() + File.separator + "invoiceTemplate.tex"); File tempDir = new File(workingDirectory.getAbsolutePath() + File.separator + "temp"); if (!tempDir.isDirectory()) { tempDir.mkdir();/* www . j a v a2 s .c o m*/ } File invoice1 = new File(tempDir.getAbsolutePath() + File.separator + "invoice1.tex"); File invoice2 = new File(tempDir.getAbsolutePath() + File.separator + "invoice2.tex"); try { HashMap<String, String> data = new HashMap<String, String>(); data.put("Number", "1"); data.put("Customer name", "Ivan Pfeiffer"); data.put("Customer street", "Schwarzer Weg 4"); data.put("Customer zip", "13505 Berlin"); data.put("Development", "Software"); data.put("Price", "500"); JLRConverter converter = new JLRConverter("::", ":::"); if (!converter.parse(template, invoice1, data)) { System.out.println(converter.getErrorMessage()); } data.put("Number", "2"); data.put("Customer name", "Mike Mueller"); data.put("Customer street", "Prenzlauer Berg 12"); data.put("Customer zip", "10405 Berlin"); data.put("Development", "Hardware"); data.put("Price", "2350"); if (!converter.parse(template, invoice2, data)) { System.out.println(converter.getErrorMessage()); } File desktop = new File(System.getProperty("user.home") + File.separator + "Desktop"); JLRGenerator pdfGen = new JLRGenerator(); pdfGen.deleteTempTexFile(false); if (!pdfGen.generate(invoice1, desktop, workingDirectory)) { System.out.println(pdfGen.getErrorMessage()); } JLROpener.open(pdfGen.getPDF()); if (!pdfGen.generate(invoice2, desktop, workingDirectory)) { System.out.println(pdfGen.getErrorMessage()); } JLROpener.open(pdfGen.getPDF()); } catch (IOException ex) { System.err.println(ex.getMessage()); } }
From source file:com.nuance.expertassistant.HTTPConnection.java
public static void main(String[] args) throws Exception { String url = "http://ibm-dqa8.grid.nuance.com:8080/question?"; HTTPConnection http = new HTTPConnection(); System.out.println("\nTesting 2 - Send Http POST request"); HashMap<String, String> paramMap = new HashMap<String, String>(); paramMap.put("contextId", "451425"); paramMap.put("question", "touch screen with beats audio"); http.sendPost(url, paramMap);/*from w w w . j a va 2s.com*/ }
From source file:com.sm.replica.DefaultReplicaServer.java
public static void main(String[] args) { String[] opts = new String[] { "-store", "-path", "-port", "-mode", "index" }; String[] defaults = new String[] { "replica", "./data", "7120", "0", "0" }; String[] paras = getOpts(args, opts, defaults); String store = paras[0];//from w w w . j a v a 2s . com int port = Integer.valueOf(paras[2]); String path = paras[1]; int mode = Integer.valueOf(paras[3]); int index = Integer.valueOf(paras[4]); CacheStore cacheStore = new CacheStore(path, null, mode); LogChannel logChannel = new LogChannel(store, 0, path); DefaultReplicaServer defaultReplicaServer = new DefaultReplicaServer(logChannel, index, store, path); HashMap<String, CacheStore> storesMap = new HashMap<String, CacheStore>(); storesMap.put(store, cacheStore); UnisonServerHandler unisonServerHandler = new UnisonServerHandler(defaultReplicaServer); logger.info("start server at " + port); ReplicaServer server = new ReplicaServer(port, storesMap, unisonServerHandler); defaultReplicaServer.hookShutdown(); }
From source file:contractEditor.contractHOST4.java
public static void main(String[] args) { JSONObject obj = new JSONObject(); obj.put("name", "HOST4"); obj.put("context", "VM-deployment"); //obj.put("Context", new Integer); HashMap serviceDescription = new HashMap(); serviceDescription.put("location", "France"); serviceDescription.put("certificate", "true"); serviceDescription.put("volume", "100_GB"); serviceDescription.put("price", "3_euro"); obj.put("serviceDescription", serviceDescription); HashMap gauranteeTerm = new HashMap(); gauranteeTerm.put("availability", "more_98_percentage"); obj.put("gauranteeTerm", gauranteeTerm); //Constraint1 ArrayList creationConstraint1 = new ArrayList(); ArrayList totalConstraint = new ArrayList(); totalConstraint.add(creationConstraint1); obj.put("creationConstraint", totalConstraint); try {//w w w. j ava2 s. c o m FileWriter file = new FileWriter("confSP" + File.separator + "Host4.json"); file.write(obj.toJSONString()); file.flush(); file.close(); } catch (IOException e) { e.printStackTrace(); } System.out.print(obj); /* JSONParser parser = new JSONParser(); try { Object obj2 = parser.parse(new FileReader("confSP\\confHost1.json")); JSONObject jsonObject = (JSONObject) obj2; HashMap serviceDescription2=(HashMap) jsonObject.get("serviceDescription"); method.printHashMap(serviceDescription2); HashMap gauranteeTerm2=(HashMap) jsonObject.get("gauranteeTerm"); method.printHashMap(gauranteeTerm2); ArrayList creationConstraint=(ArrayList) jsonObject.get("creationConstraint"); method.printArrayList(creationConstraint); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } */ }
From source file:io.covert.binary.analysis.ExecutorThread.java
public static void main(String[] args) throws Exception { HashMap<String, Object> substitutionMap = new HashMap<String, Object>(); substitutionMap.put("file", "/home/jtrost/workspace/hadoop-binary-analysis/pom.xml"); ExecutorThread e = new ExecutorThread("sha1sum", new String[] { "${file}" }, substitutionMap, new int[] { 0, 1 }, Long.MAX_VALUE, new File("/tmp")); e.start();// ww w. ja va 2s . c om e.join(); System.out.println("exitCode = " + e.getExitCode()); System.out.println("exitCode = " + e.getExecuteException()); if (e.isProcessStarted() && !e.isProcessDestroyed()) { System.out.println("stdout: " + new String(e.getStdOut().toByteArray())); System.out.println("stderr: " + new String(e.getStdErr().toByteArray())); } else if (e.isProcessStarted()) { System.out.println("Process was launched, but process destroyed"); } else { System.out.println("Process not launched"); } }
From source file:it.eng.spagobi.behaviouralmodel.lov.service.GridMetadataContainer.java
public static void main(String args[]) { GridMetadataContainer gmc = new GridMetadataContainer(); gmc.setResults(2);/* w w w. j ava 2s . c om*/ gmc.getFields().add("strNumber"); HashMap am = new HashMap<String, String>(); am.put("a", "a"); am.put("b", "b"); gmc.getFields().add(am); HashMap am2 = new HashMap<String, String>(); am2.put("1", "1"); am2.put("2", "2"); gmc.getFields().add(am2); HashMap am3 = new HashMap<String, String>(); am3.put("11a", "11a"); am3.put("11b", "11b"); gmc.getValues().add(am3); HashMap am4 = new HashMap<String, String>(); am4.put("111", "111"); am4.put("112", "112"); gmc.getValues().add(am4); try { System.out.println(gmc.toJSONString()); } catch (Exception e) { System.out.println("ssss"); } }
From source file:Main.java
public static void main(String[] args) { HashMap<String, Double> map = new HashMap<String, Double>(); ValueComparator bvc = new ValueComparator(map); TreeMap<String, Double> sorted_map = new TreeMap<String, Double>(bvc); map.put("A", 9.0); map.put("B", 6.0); map.put("C", 7.0); map.put("D", 10.0); System.out.println("unsorted map: " + map); sorted_map.putAll(map);//w ww .jav a 2 s.c o m System.out.println("results: " + sorted_map); }
From source file:com.sm.replica.grizzly.DefaultReplicaServer.java
public static void main(String[] args) { String[] opts = new String[] { "-store", "-path", "-port", "-mode", "index" }; String[] defaults = new String[] { "replica", "./data", "7120", "0", "0" }; String[] paras = getOpts(args, opts, defaults); String store = paras[0];/*from ww w . ja v a 2s .c om*/ int port = Integer.valueOf(paras[2]); String path = paras[1]; int mode = Integer.valueOf(paras[3]); int index = Integer.valueOf(paras[4]); CacheStore cacheStore = new CacheStore(path, null, mode); LogChannel logChannel = new LogChannel(store, index, path); DefaultReplicaServer defaultReplicaServer = new DefaultReplicaServer(logChannel, index, store, path); HashMap<String, CacheStore> storesMap = new HashMap<String, CacheStore>(); storesMap.put(store, cacheStore); UnisonFilter unisonServerFilter = new UnisonFilter(defaultReplicaServer); unisonServerFilter.setFreq(1); logger.info("start server at " + port); ReplicaServer server = new ReplicaServer(port, storesMap, unisonServerFilter); defaultReplicaServer.hookShutdown(); logger.info("set main thread to wait()"); try { //System.in.read(); Object obj = new Object(); synchronized (obj) { obj.wait(); } } catch (Exception io) { logger.error(io.getMessage(), io); } }