List of usage examples for java.util Set toArray
Object[] toArray();
From source file:MainClass.java
public static void main(String args[]) throws Exception { CertificateFactory cf = CertificateFactory.getInstance("X.509"); List mylist = new ArrayList(); FileInputStream in = new FileInputStream(args[0]); Certificate c = cf.generateCertificate(in); mylist.add(c);// ww w .j a v a 2s . c om CertStoreParameters cparam = new CollectionCertStoreParameters(mylist); CertStore cs = CertStore.getInstance("Collection", cparam); X509CertSelector selec = new X509CertSelector(); selec.setIssuer("CN=YourName,OU=Network Center," + "O=University,L=ZB,ST=Toronto,C=CN"); Set clct = (Set) cs.getCertificates(selec); Object o[] = clct.toArray(); for (int i = 0; i < o.length; i++) { X509Certificate ct = (X509Certificate) o[i]; System.out.println("Certificate " + i + " "); System.out.println(ct.getSubjectDN()); } }
From source file:Main.java
public static void main(String[] a) { String elements[] = { "A", "B", "C", "D", "E" }; Set<String> set = new HashSet<String>(Arrays.asList(elements)); Object[] arrObj = set.toArray(); for (int i = 0; i < arrObj.length; i++) { System.out.println(arrObj[i]); }// ww w. j av a 2s . c o m System.out.println(set); }
From source file:RBPropDemo.java
public static void main(String[] args) { ResourceBundle.clearCache();//from w w w.j av a 2s. c om String bundleName = "myproj.MyResources"; ResourceBundle myResources = ResourceBundle.getBundle(bundleName, Locale.GERMAN); System.out.println("Key's values:"); System.out.println(myResources.getString("okKey")); System.out.println(myResources.getString("cancelKey")); System.out.println(myResources.getString("submitKey")); System.out.println("\nChecking okKey in resource bundle:"); if (myResources.containsKey("okKey")) { System.out.println("okKey exists! " + " Value = " + myResources.getString("okKey")); } else { System.out.println("The key Doesn't Exist"); } System.out.println("\nGet a set of keys:"); Set<String> keySet = myResources.keySet(); Object[] keys = keySet.toArray(); for (int i = 0; i < keys.length; i++) { System.out.println("Key " + (i + 1) + " = " + keys[i]); } }
From source file:Main.java
public static void main(String[] a) { Map<String, String> yourMap = new HashMap<String, String>(); yourMap.put("1", "one"); yourMap.put("2", "two"); yourMap.put("3", "three"); Map<String, Object> map = new LinkedHashMap<String, Object>(); List<String> keyList = new ArrayList<String>(yourMap.keySet()); List<String> valueList = new ArrayList<String>(yourMap.values()); Set<String> sortedSet = new TreeSet<String>(valueList); Object[] sortedArray = sortedSet.toArray(); int size = sortedArray.length; for (int i = 0; i < size; i++) { map.put(keyList.get(valueList.indexOf(sortedArray[i])), sortedArray[i]); }/*from w w w .j a v a 2 s . co m*/ Set ref = map.keySet(); Iterator it = ref.iterator(); while (it.hasNext()) { String i = (String) it.next(); System.out.println(i); } }
From source file:Main.java
private synchronized static int getLastKey() { Set<Integer> set = mapNotify.keySet(); if (set.size() == 0) { return 0; }//from w w w . j a v a 2s . co m return (int) set.toArray()[set.size() - 1]; }
From source file:Main.java
private static String getPrefix(Set<String> names) { if (names.isEmpty()) { return ""; }//from w w w . j a v a 2 s . c om String name = (String) names.toArray()[0]; return name.substring(0, name.lastIndexOf("_")); }
From source file:Main.java
/** * // www. j a v a2 s. co m * pre: takes a valid resultSet List, a columnName to group by, a valid * comparator for the columnName's value<br> * post: separates the list into a List of List with each sub-list having the * same columnName value sorted by the keyComparator * * @param resultSet * @param columnName * @param keyComparator * @return null if resultSet is null */ @SuppressWarnings("rawtypes") public static List<List<Map>> splitSqlList(List<Map> resultSet, String columnName, Comparator keyComparator) { if (resultSet == null) return null; Map<Object, List<Map>> map = sqlMapListToMap(resultSet, columnName); Set keys = map.keySet(); Object[] keyArray = keys.toArray(); if (keyComparator == null) { Arrays.sort(keyArray); } else { Arrays.sort(keyArray, keyComparator); } List<List<Map>> rs = new ArrayList<List<Map>>(keyArray.length); for (Object key : keyArray) { rs.add(map.get(key)); } return rs; }
From source file:de.christianseipl.utilities.maputils.MapPrinting.java
public static <K> void printSet(String _header, Set<K> _set) { Object[] elements = _set.toArray(); System.out.println(_header);/*w w w . jav a2s. c o m*/ System.out.printf("[ "); for (int i = 0; i < elements.length - 1; i++) { System.out.printf("%s, ", elements[i].toString()); } if (elements.length > 0) { System.out.printf("%s ", elements[elements.length - 1].toString()); } System.out.printf("]"); System.out.println(); System.out.println(); }
From source file:Main.java
public static String getMapString(Map map) { Set set = map.keySet(); if (set.size() < 1) { return "[]"; }/*from w w w . j a v a2 s . com*/ StringBuilder strBuilder = new StringBuilder(); Object[] array = set.toArray(); strBuilder.append("[").append(array[0]).append("=").append(map.get(array[0])); for (int i = 1; i < array.length; ++i) { strBuilder.append(", "); strBuilder.append(array[i]).append("="); strBuilder.append(map.get(array[i])); } strBuilder.append("]"); return strBuilder.toString(); }
From source file:Main.java
public static String removeRepeat(String s) { Set<Object> tempSet = new HashSet<Object>(); String[] t = s.split(","); for (int i = 0; i < t.length; i++) { tempSet.add(t[i]);/*from www. j ava 2s. c o m*/ } Object[] tempObject = tempSet.toArray(); String temp = ""; for (int i = 0; i < tempObject.length; i++) { temp += tempObject[i] + ","; } return temp; }