List of usage examples for java.util Enumeration nextElement
E nextElement();
From source file:Main.java
public static void main(String[] argv) throws Exception { FileInputStream is = new FileInputStream("your.keystore"); KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); keystore.load(is, "my-keystore-password".toCharArray()); Enumeration e = keystore.aliases(); for (; e.hasMoreElements();) { String alias = (String) e.nextElement(); java.security.cert.Certificate cert = keystore.getCertificate(alias); if (cert instanceof X509Certificate) { X509Certificate x509cert = (X509Certificate) cert; // Get subject Principal principal = x509cert.getSubjectDN(); String subjectDn = principal.getName(); // Get issuer principal = x509cert.getIssuerDN(); String issuerDn = principal.getName(); }/*from w w w . ja v a 2s .c om*/ } }
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;//from w w w . ja v a 2s . c o m 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:MainClass.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(); int method = je.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 w w w . j av a 2 s .c o m*/ 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) + "%"); } } }
From source file:Main.java
public static void main(String[] argv) { DefaultTableModel model = new DefaultTableModel() { public Class getColumnClass(int columnIndex) { Object o = getValueAt(0, columnIndex); if (o == null) { return Object.class; } else { return o.getClass(); }/*from w ww. ja va2s .c om*/ } }; JTable table = new JTable(model); model.addColumn("Boolean", new Object[] { Boolean.TRUE }); model.addColumn("Date", new Object[] { new Date() }); model.addColumn("Double", new Object[] { new Double(Math.PI) }); model.addColumn("Float", new Object[] { new Float(1.2) }); model.addColumn("Icon", new Object[] { new ImageIcon("icon.gif") }); model.addColumn("Number", new Object[] { new Integer(1) }); model.addColumn("Object", new Object[] { "object" }); Enumeration e = table.getColumnModel().getColumns(); TableColumn col = (TableColumn) e.nextElement(); col.setCellRenderer(table.getDefaultRenderer(Boolean.class)); col.setCellEditor(table.getDefaultEditor(Boolean.class)); JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); while (e.hasMoreElements()) { NetworkInterface nif = e.nextElement(); System.out.println("Name: " + nif.getName() + ", Supports Multicast: " + nif.supportsMulticast() + ", isUp(): " + nif.isUp()); }/* w w w .j av a 2s .co m*/ }
From source file:MainClass.java
public static void main(String[] args) { try {/*from w ww. ja v a 2 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); } }
From source file:Main.java
public static void main(String[] args) throws Exception { ZipFile zf = new ZipFile("a.zip"); Enumeration e = zf.entries(); while (e.hasMoreElements()) { ZipEntry ze = (ZipEntry) e.nextElement(); String name = ze.getName(); long uncompressedSize = ze.getSize(); long compressedSize = ze.getCompressedSize(); long crc = ze.getCrc(); int method = ze.getMethod(); String comment = ze.getComment(); System.out.println(name + " was stored at " + new Date(ze.getTime())); if (method == ZipEntry.STORED) { System.out.println("with a size of " + uncompressedSize + " bytes"); } else if (method == ZipEntry.DEFLATED) { System.out.println("from " + uncompressedSize + " bytes to " + compressedSize); } else {/*from w w w . ja v a2s . c om*/ System.out.println("from " + uncompressedSize + " bytes to " + compressedSize); } System.out.println("Its CRC is " + crc); if (comment != null && !comment.equals("")) { System.out.println(comment); } if (ze.isDirectory()) { System.out.println(name + " is a directory"); } } }
From source file:Main.java
public static void main(String[] args) throws IOException { JarFile jf = new JarFile("a.jar"); Enumeration e = jf.entries(); while (e.hasMoreElements()) { JarEntry je = (JarEntry) e.nextElement(); System.out.println(je.getName()); long uncompressedSize = je.getSize(); long compressedSize = je.getCompressedSize(); long crc = je.getCrc(); int method = je.getMethod(); String comment = je.getComment(); System.out.println(new Date(je.getTime())); System.out.println("from " + uncompressedSize + " bytes to " + compressedSize); if (method == ZipEntry.STORED) { System.out.println("ZipEntry.STORED"); } else if (method == ZipEntry.DEFLATED) { System.out.println(ZipEntry.DEFLATED); }/*from w ww . jav a 2 s . c o m*/ System.out.println("Its CRC is " + crc); System.out.println(comment); System.out.println(je.isDirectory()); 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]); } } System.out.println(); } }
From source file:Main.java
public static void main(String args[]) { // create array list object List<String> arrlist = new ArrayList<String>(); // populate the list arrlist.add("A"); arrlist.add("B"); arrlist.add("from java2s.com"); // create Enumeration Enumeration<String> e = Collections.enumeration(arrlist); while (e.hasMoreElements()) { System.out.println("Value is: " + e.nextElement()); }//from w w w.ja v a2 s . c om }
From source file:ArrayToVector.java
public static void main(String[] args) { Object[] a1d = { "Hello World", new Date(), Calendar.getInstance(), }; // Arrays.asList(Object[]) --> List List l = Arrays.asList(a1d); // Vector contstructor takes Collection // List is a subclass of Collection Vector v;/*from ww w . ja v a 2 s . c om*/ v = new Vector(l); // Or, more simply: v = new Vector(Arrays.asList(a1d)); // Just to prove that it worked. Enumeration e = v.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }