Example usage for java.util Map keySet

List of usage examples for java.util Map keySet

Introduction

In this page you can find the example usage for java.util Map keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Map map = new HashMap();

    for (Iterator it = map.keySet().iterator(); it.hasNext();) {
        Object key = it.next();//  ww w.  j  a  v a 2 s .  c o m
    }
}

From source file:Main.java

public static void main(String[] args) {
    Map map = System.getenv();

    Set keys = map.keySet();
    Iterator iterator = keys.iterator();
    while (iterator.hasNext()) {
        String key = (String) iterator.next();
        String value = (String) map.get(key);

        System.out.println(key + " = " + value);
    }//from w ww . jav  a 2s.  c  om
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Map map = new HashMap();

    Object[] objectArray = map.keySet().toArray();
    MyClass[] array = (MyClass[]) map.keySet().toArray(new MyClass[map.keySet().size()]);

}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    PdfReader reader = new PdfReader("2.pdf");
    Map info = reader.getInfo();
    for (Iterator i = info.keySet().iterator(); i.hasNext();) {
        String key = (String) i.next();
        String value = (String) info.get(key);
        System.out.println(key + ": " + value);
    }/*from ww w  .  j  a  v  a2s .  c  o m*/
    if (reader.getMetadata() == null) {
        System.out.println("No XML Metadata.");
    } else {
        System.out.println("XML Metadata: " + new String(reader.getMetadata()));
    }
}

From source file:MainClass.java

public static void main(String[] args) {
    Map charsets = Charset.availableCharsets();
    Iterator iterator = charsets.keySet().iterator();
    while (iterator.hasNext()) {
        System.out.println(iterator.next());
    }/*w w  w  .  j  a v a 2s.c  o m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JarFile jarfile = new JarFile("filename.jar");

    Manifest manifest = jarfile.getManifest();

    Map map = manifest.getEntries();

    for (Iterator it = map.keySet().iterator(); it.hasNext();) {
        String entryName = (String) it.next();

        Attributes attrs = (Attributes) map.get(entryName);

        for (Iterator it2 = attrs.keySet().iterator(); it2.hasNext();) {
            Attributes.Name attrName = (Attributes.Name) it2.next();

            String attrValue = attrs.getValue(attrName);
        }/*from   w  w  w. j a va2 s .  c o  m*/
    }
}

From source file:Main.java

public static void main(String[] args) {
    Map<String, Charset> map = Charset.availableCharsets();
    Set<String> keys = map.keySet();
    System.out.println("Available  Character Set  Count:   " + keys.size());

    for (String charsetName : keys) {
        System.out.println(charsetName);
    }/*from   w w  w .  ja  v a 2s  .  c  o m*/
}

From source file:MainClass.java

public static void main(String[] args) {
    Map charSets = Charset.availableCharsets();
    Iterator it = charSets.keySet().iterator();
    while (it.hasNext()) {
        String csName = (String) it.next();
        System.out.print(csName);
        Iterator aliases = ((Charset) charSets.get(csName)).aliases().iterator();
        if (aliases.hasNext())
            System.out.print(": ");
        while (aliases.hasNext()) {
            System.out.print(aliases.next());
            if (aliases.hasNext())
                System.out.print(", ");
        }/*  w w w. j a v  a 2 s . com*/
        System.out.println();
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String s;/*from   w ww.  ja va2 s . co m*/
    s = "http://www.y.com/authTest";
    URL url = new URL(s);

    URLConnection urlc = url.openConnection();

    Map<String, List<String>> hf = urlc.getHeaderFields();
    for (String key : hf.keySet())
        System.out.println(key + ": " + urlc.getHeaderField(key));

    System.out.println(((HttpURLConnection) urlc).getResponseCode());
}

From source file:Test.java

public static void main(String[] args) throws Exception {
    Path path = Paths.get("/home/docs/users.txt");
    Map<String, Object> attrsMap = Files.readAttributes(path, "*");
    Set<String> keys = attrsMap.keySet();

    for (String attribute : keys) {
        System.out.println(attribute + ": " + Files.getAttribute(path, attribute));
    }/*from  ww  w .  ja va2s .c om*/

}