Example usage for java.util Enumeration hasMoreElements

List of usage examples for java.util Enumeration hasMoreElements

Introduction

In this page you can find the example usage for java.util Enumeration hasMoreElements.

Prototype

boolean hasMoreElements();

Source Link

Document

Tests if this enumeration contains more elements.

Usage

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());
    }//from   ww  w  .j a v  a 2 s.co  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());
    }/* w  w  w  . j  a  va2  s .co  m*/
}

From source file:Main.java

public static void main(String[] args) throws IOException {

    JarFile jf = new JarFile(args[0]);
    Enumeration e = jf.entries();
    while (e.hasMoreElements()) {
        JarEntry je = (JarEntry) e.nextElement();
        String name = je.getName();
        Date lastModified = new Date(je.getTime());
        long uncompressedSize = je.getSize();
        long compressedSize = je.getCompressedSize();

        System.out.println(lastModified);
        System.out.println(uncompressedSize);
        System.out.println(compressedSize);
    }//from  www.j  a v a2  s . c  om
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextPane textPane = new JTextPane();

    DefaultStyledDocument doc = (DefaultStyledDocument) textPane.getDocument();
    Enumeration e = doc.getStyleNames();
    while (e.hasMoreElements()) {
        String styleName = (String) e.nextElement();
        System.out.println(styleName);

        Style style = doc.getStyle(styleName);
    }/*  w w  w.ja va2 s .c  o m*/

}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    Properties p = new Properties();
    p.load(new FileInputStream("test.txt"));
    Enumeration e = p.propertyNames();

    for (; e.hasMoreElements();) {
        System.out.println(e.nextElement());

    }/*from ww  w .j  a  v a2 s .  co m*/
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    String[] a = new String[] { "a", "b", "c" };

    Vector v = new Vector(Arrays.asList());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(v);/*from   w w  w.j a  va 2  s. c  o m*/
    oos.close();
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bais);
    Vector v2 = (Vector) ois.readObject();
    Enumeration e = v.elements();
    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    Hashtable hashtable = new Hashtable();
    hashtable.put("apple", "red");
    hashtable.put("strawberry", "red");

    Enumeration e = hashtable.keys();
    while (e.hasMoreElements()) {
        Object k = e.nextElement();
        Object v = hashtable.get(k);
        System.out.println("key = " + k + "; value = " + v);
    }/*w  w w  .j  a  v  a 2  s.c  o m*/

}

From source file:Main.java

static public void main(String args[]) throws Exception {
    int port = 80;

    NetworkInterface ni = NetworkInterface.getByName("name");
    Enumeration e = ni.getInetAddresses();
    if (!e.hasMoreElements())
        return;/* w ww .  java 2s  .  c  om*/
    InetAddress ia = (InetAddress) e.nextElement();

    ServerSocket ss = new ServerSocket(port, 20, ia);
    System.out.println("Listening");
    Socket s = ss.accept();
    System.out.println(s);
}

From source file:Main.java

public static void main(String[] args) throws IOException {

    JarFile jf = new JarFile(args[0]);
    Enumeration e = jf.entries();
    while (e.hasMoreElements()) {
        JarEntry je = (JarEntry) e.nextElement();
        String name = je.getName();

        Attributes a = je.getAttributes();
        if (a != null) {
            Object[] nameValuePairs = a.entrySet().toArray();
            for (int j = 0; j < nameValuePairs.length; j++) {
                System.out.println(nameValuePairs[j]);
            }/*ww w .  j  a  v a2  s.  c  o  m*/
        }
    }
}

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());
    }//  w  ww  .  ja  v a2  s .c om
    zipFile.close();
}