List of usage examples for java.util Enumeration nextElement
E nextElement();
From source file:OptionsMethodExample.java
public static void main(String args[]) { HttpClient client = new HttpClient(); client.getParams().setParameter("http.useragent", "Test Client"); OptionsMethod method = new OptionsMethod("http://www.google.com"); try {/*www . j a v a2 s. c o m*/ int returnCode = client.executeMethod(method); Enumeration list = method.getAllowedMethods(); while (list.hasMoreElements()) { System.err.println(list.nextElement()); } } catch (Exception e) { System.err.println(e); } finally { method.releaseConnection(); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { ZipFile zf = new ZipFile("a.zip"); Enumeration<? extends ZipEntry> files = zf.entries(); while (files.hasMoreElements()) { ZipEntry ze = files.nextElement(); System.out.println("Decompressing " + ze.getName()); System.out.println(//from w ww. j a v a2s . c o m " Compressed Size: " + ze.getCompressedSize() + " Expanded Size: " + ze.getSize() + "\n"); BufferedInputStream fin = new BufferedInputStream(zf.getInputStream(ze)); BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream(ze.getName())); int i; do { i = fin.read(); if (i != -1) fout.write(i); } while (i != -1); fout.close(); fin.close(); } zf.close(); }
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 v a 2 s.c o m*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { String zipname = "data.zip"; ZipFile zipFile = new ZipFile(zipname); Enumeration enumeration = zipFile.entries(); while (enumeration.hasMoreElements()) { ZipEntry zipEntry = (ZipEntry) enumeration.nextElement(); System.out.println("Unzipping: " + zipEntry.getName()); BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(zipEntry)); int size; byte[] buffer = new byte[2048]; BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(zipEntry.getName()), buffer.length);/*from w w w. j a v a 2s .com*/ while ((size = bis.read(buffer, 0, buffer.length)) != -1) { bos.write(buffer, 0, size); } bos.flush(); bos.close(); bis.close(); } }
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 w w . ja v a2 s .c o m } }
From source file:MainResourceBundle.java
public static void main(String[] args) { // create a new ResourceBundle with specified locale ResourceBundle bundle = MainResourceBundle.getBundle("hello", Locale.US); // print the keys Enumeration<String> enumeration = bundle.getKeys(); while (enumeration.hasMoreElements()) { System.out.println(enumeration.nextElement()); }/*from w w w . jav a2 s .co m*/ }
From source file:MainClass.java
public static void main(String[] args) { try {//ww w . j a v 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(); 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 { System.out.println(name + " was compressed using an unrecognized method at " + lastModified); System.out.println("from " + uncompressedSize + " bytes to " + compressedSize + " bytes, a savings of " + (100.0 - 100.0 * compressedSize / uncompressedSize) + "%"); } } } catch (IOException ex) { System.err.println(ex); } }
From source file:Main.java
public static void main(String[] args) throws Exception { ZipFile zf = new ZipFile("ziptest.zip"); // Get the enumeration for all zip entries and loop through them Enumeration<? extends ZipEntry> e = zf.entries(); ZipEntry entry = null;/*from w ww . j av a 2 s .com*/ while (e.hasMoreElements()) { entry = e.nextElement(); // Get the input stream for the current zip entry InputStream is = zf.getInputStream(entry); /* Read data for the entry using the is object */ // Print the name of the entry System.out.println(entry.getName()); } }
From source file:IteratorEnumeration.java
public static void main(String[] args) { Set<String> set = new HashSet<String>(); set.add("a"); set.add("b"); set.add("c"); set.add("d"); Enumeration<String> x = new IteratorEnumeration<String>(set.iterator()); while (x.hasMoreElements()) { System.out.println(x.nextElement()); }/*from w w w. j a v a 2 s . c o m*/ }
From source file:MyResources.java
public static void main(String[] args) { MyResources mr = new MyResources(); // get the keys Enumeration<String> enumeration = mr.getKeys(); // print the keys while (enumeration.hasMoreElements()) { System.out.println(enumeration.nextElement()); }//from w w w.j a v a2 s .c o m }