List of usage examples for java.util Enumeration hasMoreElements
boolean hasMoreElements();
From source file:Main.java
static public void main(String args[]) throws Exception { Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) interfaces.nextElement(); System.out.println(ni);/*from w ww .ja v a 2 s . c o m*/ } }
From source file:Main.java
public static void main(String[] args) { ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US); System.out.println(bundle.getString("hello")); Enumeration<String> enumeration = bundle.getKeys(); while (enumeration.hasMoreElements()) { System.out.println(enumeration.nextElement()); }//from www . jav a2s . com }
From source file:WordCount.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 ww w . j a va2s. c om 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:MainClass.java
public static void main(String[] args) { try {/*from w w w .ja v a 2s . c om*/ ZipFile zf = new ZipFile("your.zip"); Enumeration e = zf.entries(); while (e.hasMoreElements()) { ZipEntry ze = (ZipEntry) e.nextElement(); String name = ze.getName(); Date lastModified = new Date(ze.getTime()); long uncompressedSize = ze.getSize(); long compressedSize = ze.getCompressedSize(); System.out.println(name); System.out.println(lastModified); System.out.println(uncompressedSize); System.out.println(compressedSize); } } catch (IOException ex) { System.err.println(ex); } }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("A"); arrayList.add("B"); arrayList.add("D"); arrayList.add("E"); arrayList.add("F"); Enumeration e = Collections.enumeration(arrayList); while (e.hasMoreElements()) System.out.println(e.nextElement()); }
From source file:Main.java
public static void main(String args[]) throws Exception { Vector<String> v = new Vector<String>(); v.add("a");// w w w . java2 s .co m v.add("b"); v.add("java2s.com"); Collection<String> col = v; Enumeration<String> e = Collections.enumeration(col); for (; e.hasMoreElements();) { Object o = e.nextElement(); System.out.println(o); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Hashtable hash = new Hashtable(89); hash.put("one", "two"); hash.put("two", "three"); hash.put("three", "four"); hash.put("four", "five"); System.out.println(hash);/*from ww w. j a v a2 s .c om*/ System.out.println(hash.size()); Enumeration e = hash.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " : " + hash.get(key)); } Set set = hash.entrySet(); Iterator it = set.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); System.out.println(entry.getKey() + " : " + entry.getValue()); } }
From source file:Main.java
public static void main(String args[]) throws Exception { Vector<String> v = new Vector<String>(); v.add("a");/*from w ww. j a va2 s . c om*/ v.add("b"); v.add("c"); Collection<String> col = v; Enumeration<String> 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) throws Exception { ZipFile zf = new ZipFile("your.zip"); Enumeration e = zf.entries(); while (e.hasMoreElements()) { ZipEntry ze = (ZipEntry) e.nextElement(); String name = ze.getName(); Date lastModified = new Date(ze.getTime()); long uncompressedSize = ze.getSize(); long compressedSize = ze.getCompressedSize(); int method = ze.getMethod(); if (method == ZipEntry.STORED) { System.out.println(name + " was stored at " + lastModified); System.out.println("with a size of " + uncompressedSize + " bytes"); } else if (method == ZipEntry.DEFLATED) { System.out.println(name + " was deflated at " + lastModified); System.out.println("from " + uncompressedSize + " bytes to " + compressedSize + " bytes, a savings of " + (100.0 - 100.0 * compressedSize / uncompressedSize) + "%"); } else {//from ww w . j a va2 s . com System.out.println(name + " was compressed at " + lastModified); System.out.println("from " + uncompressedSize + " bytes to " + compressedSize + " bytes, a savings of " + (100.0 - 100.0 * compressedSize / uncompressedSize) + "%"); } } }
From source file:MainClass.java
public static void main(String[] args) { try {/* www .j a v a2 s . co m*/ ZipFile zf = new ZipFile("your.zip"); Enumeration e = zf.entries(); while (e.hasMoreElements()) { ZipEntry ze = (ZipEntry) e.nextElement(); String name = ze.getName(); long crc = ze.getCrc(); System.out.println("Its CRC is " + crc); String comment = ze.getComment(); if (comment != null && !comment.equals("")) { System.out.println(comment); } if (ze.isDirectory()) { System.out.println(name + " is a directory"); } } } catch (IOException ex) { System.err.println(ex); } }