Java examples for java.util:Hashtable Operation
Returns string keys in a hashtable as array of string
//package com.java2s; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; public class Main { /**//from ww w . j av a 2 s .c om * Returns string keys in a hashtable as array of string * * @param ht * , Hashtable * @return , string array with hash keys string */ public static synchronized String[] hashtableKeysToArray(Hashtable ht) { Vector v = new Vector(); String[] sa = null; int count = 0; Enumeration e = ht.keys(); while (e.hasMoreElements()) { String s = (String) e.nextElement(); v.addElement(s); count++; } sa = new String[count]; v.copyInto(sa); return sa; } }