List of usage examples for java.util Enumeration hasMoreElements
boolean hasMoreElements();
From source file:com.glaf.core.config.Environment.java
public static Properties getSystemPropertiesByName(String name) { Properties props = systemProperties.get(name); Properties p = new Properties(); Enumeration<?> e = props.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = props.getProperty(key); p.put(key, value);//from w ww. jav a 2 s.co m } return p; }
From source file:com.church.tools.ChartTools.java
/** * Generate pie chart.//from ww w. ja va 2s . c o m * * @param title the title * @param values the values * @param captions the captions * @param width the width * @param height the height * @param color the color * * @return the buffered image */ public static BufferedImage GeneratePieChart(String title, double[] values, String[] captions, int width, int height, Color color) { BufferedImage bufferedImage = null; DefaultPieDataset pieDataset = new DefaultPieDataset(); Hashtable<String, String> ht = new Hashtable<String, String>(); for (int i = 0; i < values.length; i++) ht.put(captions[i], Double.toString(values[i])); Enumeration<String> enu = ht.keys(); int i = 0; while (enu.hasMoreElements()) { String str = (String) enu.nextElement(); pieDataset.setValue(str, new Double(Double.parseDouble((String) ht.get(str)))); i++; } JFreeChart chart = ChartFactory.createPieChart(title, pieDataset, false, false, false); chart.setBackgroundPaint(color); bufferedImage = chart.createBufferedImage(width, height); return bufferedImage; }
From source file:adalid.util.info.JavaInfo.java
public static void printManifestInfo(String extension, boolean details, Enumeration<URL> resources) { URL url;/*ww w.j a v a2 s . c om*/ while (resources.hasMoreElements()) { try { url = resources.nextElement(); printManifestInfo(extension, details, url); } catch (Exception ex) { logger.error(ex); } } }
From source file:com.pureinfo.srm.RequestUtils.java
public static PureProperties parse(HttpServletRequest _request) throws PureException { logger.debug("enti"); PureProperties props = new PureProperties(); Enumeration names = _request.getParameterNames(); logger.debug("enti11111111111#" + names.hasMoreElements()); while (names.hasMoreElements()) { String sName = (String) names.nextElement(); String[] values = _request.getParameterValues(sName); if (values.length == 1) { props.setProperty(sName, values[0]); } else {// w w w .j a v a 2 s .c o m props.setProperty(sName, values); } } String sContentType = _request.getContentType(); if (sContentType != null && sContentType.startsWith("multipart/form-data")) { logger.debug("enti111"); DiskFileUpload upload = new DiskFileUpload(); List items; try { items = upload.parseRequest(_request); } catch (FileUploadException ex) { throw new PureException(PureException.UNKNOWN, "upload error", ex); } logger.debug("enti111111111111" + items.size()); for (Iterator iter = items.iterator(); iter.hasNext();) { FileItem item = (FileItem) iter.next(); if (item.getName() == null) { props.setProperty(item.getFieldName(), item.getString()); } else { props.setProperty(item.getFieldName(), item); } logger.debug("name:" + item.getFieldName() + "-value:" + props.getProperty(item.getFieldName())); } } return props; }
From source file:Main.java
/** * Check whether the given Enumeration contains the given element. * * @param enumeration the Enumeration to check * @param element the element to look for * @return {@code true} if found, {@code false} else *///from www.j a va 2s . co m public static boolean contains(Enumeration<?> enumeration, Object element) { if (enumeration != null) { while (enumeration.hasMoreElements()) { Object candidate = enumeration.nextElement(); if (org.springframework.util.ObjectUtils.nullSafeEquals(candidate, element)) { return true; } } } return false; }
From source file:com.google.code.fqueue.util.Config.java
/** * ??//from www .j av a 2s. c o m * * @param path * * @throws FileNotFoundException */ public static synchronized void iniSetting(String path) { File file; file = new File(path); FileInputStream in = null; try { in = new FileInputStream(file); Properties p = new Properties(); p.load(in); // ???Map Enumeration<?> item = p.propertyNames(); while (item.hasMoreElements()) { String key = (String) item.nextElement(); setting.put(key, p.getProperty(key)); } in.close(); } catch (FileNotFoundException e) { log.error("config file not found at" + file.getAbsolutePath()); throw new ConfigException("FileNotFoundException", e); } catch (IOException e) { log.error("config file not found at" + file.getAbsolutePath()); throw new ConfigException("IOException", e); } catch (Exception e) { throw new ConfigException("Exception", e); } }
From source file:Main.java
public static Collection<InetAddress> getAllAvailableAddresses() { Set<InetAddress> retval = new HashSet<InetAddress>(); Enumeration en; try {// www .j a v a 2s .c o m en = NetworkInterface.getNetworkInterfaces(); if (en == null) return retval; while (en.hasMoreElements()) { NetworkInterface intf = (NetworkInterface) en.nextElement(); Enumeration<InetAddress> addrs = intf.getInetAddresses(); while (addrs.hasMoreElements()) retval.add(addrs.nextElement()); } } catch (SocketException e) { e.printStackTrace(); } return retval; }
From source file:com.servoy.j2db.server.ngclient.startup.resourceprovider.ComponentResourcesExporter.java
/** * Used in war export to create a services.properties file, which is needed to load services specs in the war. * @return the locations of services folders relative to the war dir. *//*from w ww. j a v a 2 s .c o m*/ public static String getServicesDirectoryNames() { StringBuilder locations = new StringBuilder(); Enumeration<String> paths = Activator.getContext().getBundle().getEntryPaths("/war/"); while (paths.hasMoreElements()) { String name = paths.nextElement().replace("war/", ""); if (name.endsWith("services/")) locations.append("/" + name + ";"); } if (locations.length() > 0) locations.deleteCharAt(locations.length() - 1); return locations.toString(); }
From source file:com.servoy.j2db.server.ngclient.startup.resourceprovider.ComponentResourcesExporter.java
/** * Used in war export to create a components.properties file which is needed to load the components specs in war. * @return the locations of components folders relative to the war dir. *//*from w w w.j a v a 2 s . co m*/ public static String getComponentDirectoryNames() { StringBuilder locations = new StringBuilder(); Enumeration<String> paths = Activator.getContext().getBundle().getEntryPaths("/war/"); while (paths.hasMoreElements()) { String name = paths.nextElement().replace("war/", ""); if (name.endsWith("/") && !name.equals("js/") && !name.equals("css/") && !name.equals("templates/") && !name.endsWith("services/")) { locations.append("/" + name + ";"); } } locations.deleteCharAt(locations.length() - 1); return locations.toString(); }
From source file:Main.java
public static void unzipEPub(String inputZip, String destinationDirectory) throws IOException { int BUFFER = 2048; List zipFiles = new ArrayList(); File sourceZipFile = new File(inputZip); File unzipDestinationDirectory = new File(destinationDirectory); unzipDestinationDirectory.mkdir();//from w w w .j a va2s.c o m ZipFile zipFile; zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ); Enumeration zipFileEntries = zipFile.entries(); // Process each entry while (zipFileEntries.hasMoreElements()) { ZipEntry entry = (ZipEntry) zipFileEntries.nextElement(); String currentEntry = entry.getName(); File destFile = new File(unzipDestinationDirectory, currentEntry); if (currentEntry.endsWith(".zip")) { zipFiles.add(destFile.getAbsolutePath()); } File destinationParent = destFile.getParentFile(); destinationParent.mkdirs(); if (!entry.isDirectory()) { BufferedInputStream is = new BufferedInputStream(zipFile.getInputStream(entry)); int currentByte; // buffer for writing file byte data[] = new byte[BUFFER]; FileOutputStream fos = new FileOutputStream(destFile); BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER); while ((currentByte = is.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, currentByte); } dest.flush(); dest.close(); is.close(); } } zipFile.close(); for (Iterator iter = zipFiles.iterator(); iter.hasNext();) { String zipName = (String) iter.next(); unzipEPub(zipName, destinationDirectory + File.separatorChar + zipName.substring(0, zipName.lastIndexOf(".zip"))); } }