List of usage examples for java.util Enumeration hasMoreElements
boolean hasMoreElements();
From source file:Main.java
public static void main(String[] args) { ResourceBundle resource = ResourceBundle.getBundle("Messages", Locale.UK); Properties properties = convertResourceBundleToProperties(resource); Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = (String) properties.get(key); System.out.println(key + " = " + value); }/* w w w . jav a 2 s. co m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { SecurityManager sm = new SecurityManager(); System.setSecurityManager(sm); URL codebase = new URL("http://java.sun.com/"); //codebase = new File("c:\\java\\").toURI().toURL(); //codebase = new File(System.getProperty("user.home")).toURI().toURL(); CodeSource cs = new CodeSource(codebase, (Certificate[]) null); PermissionCollection pcoll = Policy.getPolicy().getPermissions(cs); Enumeration e = pcoll.elements(); for (; e.hasMoreElements();) { Permission p = (Permission) e.nextElement(); }//ww w .ja v a 2 s . com }
From source file:PlanetDiameters.java
public static void main(String args[]) { String names[] = { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto" }; float diameters[] = { 4800f, 12103.6f, 12756.3f, 6794f, 142984f, 120536f, 51118f, 49532f, 2274f }; Hashtable hash = new Hashtable(); for (int i = 0, n = names.length; i < n; i++) { hash.put(names[i], new Float(diameters[i])); }//w ww . j a va 2 s . c om Enumeration e = hash.keys(); Object obj; while (e.hasMoreElements()) { obj = e.nextElement(); System.out.println(obj + ": " + hash.get(obj)); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Vector v = new Vector(); v.add("a");// w w w . jav a 2 s .c o m v.add("b"); v.add("c"); Collection col = v; Enumeration e = Collections.enumeration(col); for (; e.hasMoreElements();) { Object o = e.nextElement(); System.out.println(o); } }
From source file:Main.java
public static void main(String[] args) { HashSet<String> hashSet = new HashSet<String>(); hashSet.add("A"); hashSet.add("B"); hashSet.add("D"); hashSet.add("E"); hashSet.add("F"); Enumeration e = Collections.enumeration(hashSet); while (e.hasMoreElements()) System.out.println(e.nextElement()); }
From source file:Main.java
public static void main(String[] args) { Hashtable<String, String> ht = new Hashtable<String, String>(); ht.put("1", "One"); ht.put("2", "Two"); ht.put("3", "Three"); Set st = ht.keySet();/* ww w. j a v a2 s.c om*/ Iterator itr = st.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); } st.remove("2"); Enumeration e = ht.keys(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }
From source file:Main.java
public static void main(String[] args) { Enumeration ports = CommPortIdentifier.getPortIdentifiers(); while (ports.hasMoreElements()) { CommPortIdentifier cpi = (CommPortIdentifier) ports.nextElement(); System.out.println("Port " + cpi.getName()); }/*from w w w. j a va2 s. co m*/ }
From source file:Main.java
public static void main(String[] args) { HashSet<String> hashSet = new HashSet<String>(); hashSet.add("A"); hashSet.add("B"); hashSet.add("D"); hashSet.add("E"); hashSet.add("F"); Enumeration e = Collections.enumeration(hashSet); while (e.hasMoreElements()) { System.out.println(e.nextElement()); }/*from ww w .jav a 2s.c om*/ }
From source file:MainClass.java
public static void main(String args[]) throws IOException { Hashtable map = new Hashtable(); FileReader fr = new FileReader(args[0]); BufferedReader br = new BufferedReader(fr); String line;//from w w w. jav a 2 s . com while ((line = br.readLine()) != null) { processLine(line, map); } Enumeration e = map.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " : " + map.get(key)); } }
From source file:Main.java
public static void main(String[] args) { HashMap<String, String> hMap = new HashMap<String, String>(); hMap.put("1", "One"); hMap.put("2", "Two"); hMap.put("3", "Three"); Hashtable<String, String> ht = new Hashtable<String, String>(); ht.put("1", "REPLACED !!"); ht.put("4", "Four"); Enumeration e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); }/* www. j ava 2s .c o m*/ ht.putAll(hMap); e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }