List of usage examples for java.util Enumeration nextElement
E nextElement();
From source file:Main.java
public static void main(String[] args) throws Exception { ZipFile zipFile = new ZipFile(new File("testfile.zip"), ZipFile.OPEN_READ); System.out.println(zipFile.getComment()); Enumeration zipEntries = zipFile.entries(); while (zipEntries.hasMoreElements()) { System.out.println(((ZipEntry) zipEntries.nextElement()).getName()); }// ww w. j ava2s . c o m }
From source file:Main.java
public static void main(String[] args) throws Exception { ZipFile zipFile = new ZipFile(new File("testfile.zip"), ZipFile.OPEN_DELETE); Enumeration zipEntries = zipFile.entries(); while (zipEntries.hasMoreElements()) { System.out.println(((ZipEntry) zipEntries.nextElement()).getName()); }//from ww w . j ava2s .c o m }
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);//www .j a v a 2 s .c o m 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 { ZipFile zipFile = new ZipFile("testfile.zip", Charset.defaultCharset()); Enumeration zipEntries = zipFile.entries(); while (zipEntries.hasMoreElements()) { System.out.println(((ZipEntry) zipEntries.nextElement()).getName()); }/*from www. j a va 2s . c o m*/ zipFile.close(); }
From source file:ArrayEnumerationFactory.java
public static void main(String args[]) { Enumeration e = makeEnumeration(args); while (e.hasMoreElements()) { System.out.println(e.nextElement()); }/* ww w . jav a 2 s .co m*/ e = makeEnumeration(new int[] { 1, 3, 4, 5 }); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } try { e = makeEnumeration(new Double(Math.PI)); } catch (IllegalArgumentException ex) { System.err.println("Can't enumerate that: " + ex.getMessage()); } }
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 w w w. j av a 2s .co m }
From source file:Main.java
public static void main(String[] args) throws Exception { Class driverClass = Class.forName("org.hsqldb.jdbcDriver"); DriverManager.registerDriver((Driver) driverClass.newInstance()); // Print out all loaded JDBC drivers. java.util.Enumeration e = java.sql.DriverManager.getDrivers(); while (e.hasMoreElements()) { Object driverAsObject = e.nextElement(); System.out.println("JDBC Driver=" + driverAsObject); }//from w w w . ja v a 2s . c o m }
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 {/*ww w . j a v a2 s . c o m*/ 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 {/*from w w w . j av a 2s. c o m*/ 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:ArrayEnumeration.java
public static void main(String args[]) { Object obj = new int[] { 2, 3, 5, 8, 13, 21 }; Enumeration e = new ArrayEnumeration(obj); while (e.hasMoreElements()) { System.out.println(e.nextElement()); }//from www . jav a 2 s . c o m try { e = new ArrayEnumeration("Not an Array"); } catch (IllegalArgumentException ex) { System.out.println(ex.getMessage()); } }