Example usage for java.util HashMap put

List of usage examples for java.util HashMap put

Introduction

In this page you can find the example usage for java.util HashMap put.

Prototype

public V put(K key, V value) 

Source Link

Document

Associates the specified value with the specified key in this map.

Usage

From source file:com.vina.hlexchang.HttpRequestSample.java

/**
 * @param args the command line arguments
 *///from w  ww. ja v  a 2  s.  com
public static void main(String[] args) {
    // TODO code application logic here
    ClientRequestHelper clientRequestHelper = new ClientRequestHelper();
    // clientRequestHelper.setProxy("10.61.11.39", 3128);
    HashMap<String, String> hmR = new HashMap<String, String>();
    hmR.put("User-Agent",
            "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
    hmR.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    hmR.put("Accept-Language", "en-US,en;q=0.5");
    hmR.put("Content-Type", "application/x-www-form-urlencoded");
    String result = clientRequestHelper.sendGet("http://www.otohits.net/account/login", hmR);
    Document doc = Jsoup.parse(result);
    Elements lstElement = doc.getElementsByAttributeValue("name", "__RequestVerificationToken");
    String requestVeriToken = "";
    HashMap<String, String> hmData = new HashMap<>();

    if (lstElement != null && lstElement.size() > 0) {
        requestVeriToken = lstElement.get(0).attr("value");
    }
    hmData.put("__RequestVerificationToken", requestVeriToken);
    hmData.put("Email", "getmoneykhmt3@gmail.com");
    hmData.put("Password", "asd123");
    result = clientRequestHelper.sendPost("http://www.otohits.net/account/login", hmR, hmData);
    System.out.println(result);

}

From source file:httprequestsample.HttpRequestSample.java

/**
 * @param args the command line arguments
 *///from  ww w . j a v  a2  s  .c o m
public static void main(String[] args) {
    // TODO code application logic here
    ClientRequestHelper clientRequestHelper = new ClientRequestHelper();
    clientRequestHelper.setProxy("10.61.11.39", 3128);
    HashMap<String, String> hmR = new HashMap<String, String>();
    hmR.put("User-Agent",
            "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
    hmR.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    hmR.put("Accept-Language", "en-US,en;q=0.5");
    hmR.put("Content-Type", "application/x-www-form-urlencoded");
    String result = clientRequestHelper.sendGet("http://www.otohits.net/account/login", hmR);
    Document doc = Jsoup.parse(result);
    Elements lstElement = doc.getElementsByAttributeValue("name", "__RequestVerificationToken");
    String requestVeriToken = "";
    HashMap<String, String> hmData = new HashMap<>();

    if (lstElement != null && lstElement.size() > 0) {
        requestVeriToken = lstElement.get(0).attr("value");
    }
    hmData.put("__RequestVerificationToken", requestVeriToken);
    hmData.put("Email", "getmoneykhmt3@gmail.com");
    hmData.put("Password", "asd123");
    result = clientRequestHelper.sendPost("http://www.otohits.net/account/login", hmR, hmData);
    System.out.println(result);

}

From source file:cz.cas.lib.proarc.common.process.KakaduCompress.java

public static void main(String[] args) throws Exception {
    if (args != null && args.length > 2) {
        HashMap<String, String> env = new HashMap<String, String>();
        env.put(AppConfiguration.PROPERTY_APP_HOME, args[0]);
        AppConfiguration conf = AppConfigurationFactory.getInstance().create(env);
        Configuration config = conf.getAuthenticators();
        config = new ImportProfile(config).getNdkArchivalProcessor();
        ExternalProcess ep = new KakaduCompress(config, new File(args[1]), new File(args[2]));
        ep.run();/*from  ww  w  .j  av  a2  s  .c  o  m*/
    }
}

From source file:Main.java

public static void main(String[] args) {
    HashMap<String, String> hMap = new HashMap<String, String>();

    System.out.println("Size of HashMap : " + hMap.size());

    hMap.put("1", "One");
    hMap.put("2", "Two");
    hMap.put("3", "Three");

    System.out.println("Size of HashMap after addition : " + hMap.size());

    // remove one element from HashMap
    System.out.println(hMap.remove("2"));
}

From source file:MainClass.java

License:asdf

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*from   w w w  . j  av a2  s. co m*/
    Paragraph hello = new Paragraph("asdf");
    Chapter universe = new Chapter("A", 1);
    Section section;
    section = universe.addSection("B");
    section.add(hello);
    section = universe.addSection("C");
    section.add(hello);
    document.close();
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    PdfReader reader = new PdfReader("2.pdf");
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("HelloWorldManipulateBookmarks.pdf"));
    stamper.insertPage(1, PageSize.A4);
    PdfContentByte cb = stamper.getOverContent(1);
    cb.beginText();
    cb.setFontAndSize(bf, 18);
    cb.setTextMatrix(36, 770);
    cb.showText("Inserted Title Page");
    cb.endText();
    stamper.addAnnotation(PdfAnnotation.createText(stamper.getWriter(), new Rectangle(30f, 750f, 80f, 800f),
            "inserted page", "This page is the title page.", true, null), 1);
    List list = SimpleBookmark.getBookmark(reader);
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("Title", "Title Page");
    ArrayList kids = new ArrayList();
    HashMap<String, String> kid1 = new HashMap<String, String>();
    kid1.put("Title", "top");
    kid1.put("Action", "GoTo");
    kid1.put("Page", "1 ");
    kids.add(kid1);
    HashMap<String, String> kid2 = new HashMap<String, String>();
    kid2.put("Title", "bottom");
    kid2.put("Action", "GoTo");
    kid2.put("Page", "6");
    kids.add(kid2);
    map.put("Kids", kids);
    list.add(0, map);
    SimpleBookmark.exportToXML(list, new FileOutputStream("manipulated_bookmarks.xml"), "ISO8859-1", true);
    stamper.setOutlines(list);
    stamper.close();
}

From source file:invoice.GetInvoice.java

/**
 * @param args the command line arguments
 *///from  w  w  w.j av  a2s  . co m
public static void main(String[] args) {

    NumberFormat nf = NumberFormat.getInstance();
    nf.setGroupingUsed(false);
    nf.setMaximumFractionDigits(2);
    nf.setMinimumFractionDigits(2);
    nf.setRoundingMode(RoundingMode.HALF_UP);

    try {
        JSONObject arg_json = new JSONObject(args[0]);
    } catch (JSONException ex) {
        Logger.getLogger(GetInvoice.class.getName()).log(Level.SEVERE, null, ex);
    }
    HashMap<String, Object> hm = new HashMap<>();
    hm.put("duplicate", "");
    hm.put("distributor", "//oshan" + "\n" + "//kapuhempala" + "\n\nArea: " + "//galle");
    hm.put("customer", "//owner" + "\n" + "//Agro" + "\n" + "//Agro add" + "\n" + "//0771894851");
    hm.put("invNo", "GSLTS" + String.format("%04d", Integer.parseInt("//100")));
    hm.put("invDate", "2014-01-10");
    hm.put("invCode", "300");

    double invoiceTotal = 500000;
    if (5 > 0) {//ShopDiscount
        double discountprice = (invoiceTotal * 99) / 100;//getShopDiscount()
        hm.put("invoiceDiscount", nf.format((invoiceTotal) * 99 / 100));//getRetail_discount()

    } else {
        hm.put("invoiceDiscount", "");
    }
    hm.put("gross_total", nf.format(invoiceTotal));
    hm.put("invoiceTotal", nf.format(((invoiceTotal) * (100 - 99) / 100)));//getRetail_discount()
    hm.put("salesPersonName", "rep");
    hm.put("salesPersonContactNo", "0772189584");

    JTable jTable1 = new JTable();
    jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
            new String[] { "ITEMCODE", "DESCRIPTION", "QTY", "FREEQTY", "PRICE", "AMOUNT" }));
    String reportSource = "./ireports/invoice.jrxml";
    DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
    try {
        JasperReport jr = JasperCompileManager.compileReport(reportSource);
        JasperPrint jp = JasperFillManager.fillReport(jr, hm, new JRTableModelDataSource(dtm));
        JasperPrintManager.printReport(jp, false);
    } catch (JRException ex) {
        Logger.getLogger(GetInvoice.class.getName()).log(Level.SEVERE, null, ex);
    }
    System.out.println("1");
}

From source file:Main.java

public static void main(String[] args) {
    ReferenceQueue referenceQueue = new ReferenceQueue();
    Object object = new Object() {
        public String toString() {
            return "Referenced Object";
        }//from  w  ww . j  av a 2 s .co  m
    };
    Object data = new Object() {
        public String toString() {
            return "Data";
        }
    };

    HashMap map = new HashMap();
    Reference reference = new SoftReference(object, referenceQueue);

    map.put(reference, data);

    System.out.println(reference.get());
    System.out.println(map.get(reference));
    System.out.println(reference.isEnqueued());

    System.gc();
    System.out.println(reference.get());
    System.out.println(map.get(reference));
    System.out.println(reference.isEnqueued());

    object = null;
    data = null;

    System.gc();
    System.out.println(reference.get());
    System.out.println(map.get(reference));
    System.out.println(reference.isEnqueued());
}

From source file:Main.java

public static void main(String[] args) {
    ReferenceQueue referenceQueue = new ReferenceQueue();
    Object object = new Object() {
        public String toString() {
            return "Referenced Object";
        }/*from  w  w  w.j  a  v a  2s  .c  o m*/
    };

    Object data = new Object() {
        public String toString() {
            return "Data";
        }
    };

    HashMap map = new HashMap();
    Reference reference = new SoftReference(object, referenceQueue);

    map.put(reference, data);

    System.out.println(reference.get());
    System.out.println(map.get(reference));
    System.out.println(reference.isEnqueued());

    System.gc();
    System.out.println(reference.get());
    System.out.println(map.get(reference));
    System.out.println(reference.isEnqueued());

    object = null;
    data = null;

    System.gc();
    System.out.println(reference.get());
    System.out.println(map.get(reference));
    System.out.println(reference.isEnqueued());
}

From source file:com.zimbra.cs.account.PreAuthKey.java

public static void main(String args[]) throws ServiceException {
    long now = System.currentTimeMillis();
    HashMap<String, String> params = new HashMap<String, String>();
    params.put("account", "user1");
    params.put("by", "name");
    params.put("timestamp", "1176399950434");
    params.put("expires", "0");
    String key = "9d8ad87fd726ba7d5fecf3d705621024b31cedb142310ec965f9263568fa0f27";
    System.out.printf("key=%s preAuth=%s\n", key, computePreAuth(params, key));
}

From source file:de.ingrid.iplug.AdminServer.java

/**
 * To start the admin web server from the commandline. 
 * @param args The server port and the web app folder. 
 * @throws Exception Something goes wrong.
 *//*from w ww.  j  a va 2s.  c  o m*/
public static void main(String[] args) throws Exception {

    String usage = "<serverPort> <webappFolder>";
    if ((args.length == 0) && (args.length != 4) && (args.length != 6)) {
        System.err.println(usage);
        return;
    }

    Map arguments = readParameters(args);
    File plugDescriptionFile = new File(PLUG_DESCRIPTION);
    if (arguments.containsKey("--plugdescription")) {
        plugDescriptionFile = new File((String) arguments.get("--plugdescription"));
    }
    File communicationProperties = new File(COMMUNICATION_PROPERTES);
    if (arguments.containsKey("--descriptor")) {
        communicationProperties = new File((String) arguments.get("--descriptor"));
    }

    int port = Integer.parseInt(args[0]);
    File webFolder = new File(args[1]);

    //push init params for all contexts (e.g. step1 and step2)
    HashMap hashMap = new HashMap();
    hashMap.put("plugdescription.xml", plugDescriptionFile.getAbsolutePath());
    hashMap.put("communication.xml", communicationProperties.getAbsolutePath());

    WebContainer container = startWebContainer(hashMap, port, webFolder, false, null);
    container.join();
}