public static String getIPAddress(boolean useIPv4) throws SocketException { List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { List<InetAddress> addrs = Collections.list(intf.getInetAddresses()); for (InetAddress addr : addrs) { if (!addr.isLoopbackAddress()) { String sAddr = addr.getHostAddress().toUpperCase(); boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr); if (useIPv4) { if (isIPv4) return sAddr; } else { if (!isIPv4) { if (sAddr.startsWith("fe80") || sAddr.startsWith("FE80")) // skipping link-local addresses continue; int delim = sAddr.indexOf('%'); // drop ip6 port suffix return delim < 0 ? sAddr : sAddr.substring(0, delim); } } } } } return ""; }
/** * Prefer something other than loopback. * * @return * @throws SocketException * @throws UnknownHostException */ public static InetAddress getInetAddress() throws SocketException, UnknownHostException { // try to use eth0 if found NetworkInterface eth0 = NetworkInterface.getByName("eth0"); if (eth0 != null) { Enumeration<InetAddress> addresses = eth0.getInetAddresses(); for (InetAddress address : Collections.list(addresses)) { if (address instanceof Inet4Address) { return address; } } } // something other than eth0 or loopback Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); for (NetworkInterface iface : Collections.list(interfaces)) { Enumeration<InetAddress> addresses = iface.getInetAddresses(); for (InetAddress address : Collections.list(addresses)) { if (address instanceof Inet4Address && !address.isLoopbackAddress()) { return address; } } } // default, probably loopback return InetAddress.getLocalHost(); }
public static String getLocalIpAddress2() { String networkIp = null; try { List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface iface : interfaces) { if (iface.getDisplayName().equals("eth0")) { List<InetAddress> addresses = Collections.list(iface.getInetAddresses()); for (InetAddress address : addresses) { if (address instanceof Inet4Address) { networkIp = address.getHostAddress(); } } } else if (iface.getDisplayName().equals("wlan0")) { List<InetAddress> addresses = Collections.list(iface.getInetAddresses()); for (InetAddress address : addresses) { if (address instanceof Inet4Address) { networkIp = address.getHostAddress(); } } } } } catch (SocketException e) { e.printStackTrace(); } return networkIp; }
/** * Get IP address from first non-localhost interface * * @param ipv4 true=return ipv4, false=return ipv6 * @return address or empty string */ public static String getIPAddress(boolean useIPv4) { try { List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { List<InetAddress> addrs = Collections.list(intf.getInetAddresses()); for (InetAddress addr : addrs) { if (!addr.isLoopbackAddress()) { String sAddr = addr.getHostAddress().toUpperCase(); boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr); if (useIPv4) { if (isIPv4) return sAddr; } else { if (!isIPv4) { int delim = sAddr.indexOf('%'); // drop ip6 port // suffix return delim < 0 ? sAddr : sAddr.substring(0, delim); } } } } } } catch (Exception ex) { } // for now eat exceptions return ""; }
private NetworkInterface GetExternalNetworkInterface() { try { // iterate over the network interfaces known to java Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); OUTER: for (NetworkInterface interface_ : Collections.list(interfaces)) { // we shouldn't care about loopback addresses if (interface_.isLoopback()) continue; // if you don't expect the interface to be up you can skip this // though it would question the usability of the rest of the code if (!interface_.isUp()) continue; // iterate over the addresses associated with the interface Enumeration<InetAddress> addresses = interface_.getInetAddresses(); for (InetAddress address : Collections.list(addresses)) { // look only for ipv4 addresses if (address instanceof Inet6Address) continue; // use a timeout big enough for your needs if (!address.isReachable(3000)) continue; return interface_; } } } catch (Exception e) { e.printStackTrace(); } return null; }
public static Set<String> getIpAddresses() { if (_ipAddresses == null) { _ipAddresses = new HashSet<String>(); try { List<NetworkInterface> networkInterfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface networkInterface : networkInterfaces) { List<InetAddress> inetAddresses = Collections.list(networkInterface.getInetAddresses()); for (InetAddress inetAddress : inetAddresses) { if (inetAddress.isLinkLocalAddress() || inetAddress.isLoopbackAddress() || !(inetAddress instanceof Inet4Address)) { continue; } _ipAddresses.add(inetAddress.getHostAddress()); } } } catch (Exception e) { _log.error("Unable to read local server's IP addresses"); _log.error(e, e); } } return new HashSet<String>(_ipAddresses); }
private static InetAddress findPublicIp() { // Check if local host address is a good v4 address InetAddress localAddress; try { localAddress = InetAddress.getLocalHost(); if (isGoodV4Address(localAddress)) { return localAddress; } } catch (UnknownHostException ignored) { throw new AssertionError("Could not get local ip address"); } // check all up network interfaces for a good v4 address for (NetworkInterface networkInterface : getGoodNetworkInterfaces()) { for (InetAddress address : Collections.list(networkInterface.getInetAddresses())) { if (isGoodV4Address(address)) { return address; } } } // check all up network interfaces for a good v6 address for (NetworkInterface networkInterface : getGoodNetworkInterfaces()) { for (InetAddress address : Collections.list(networkInterface.getInetAddresses())) { if (isGoodV6Address(address)) { return address; } } } // just return the local host address // it is most likely that this is a disconnected developer machine return localAddress; }
private static void displayInterfaceInformation(final NetworkInterface networkInterface) throws SocketException { LOG.trace(MessageFormat.format("Display name: %s%n", networkInterface.getDisplayName())); LOG.trace(MessageFormat.format("Name: %s%n", networkInterface.getName())); Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses(); for (InetAddress inetAddress : Collections.list(inetAddresses)) { LOG.trace(MessageFormat.format("InetAddress: %s%n", inetAddress)); } LOG.trace(MessageFormat.format("Parent: %s%n", networkInterface.getParent())); LOG.trace(MessageFormat.format("Up? %s%n", networkInterface.isUp())); LOG.trace(MessageFormat.format("Loopback? %s%n", networkInterface.isLoopback())); LOG.trace(MessageFormat.format("PointToPoint? %s%n", networkInterface.isPointToPoint())); LOG.trace(MessageFormat.format("Supports multicast? %s%n", networkInterface.isVirtual())); LOG.trace(MessageFormat.format("Virtual? %s%n", networkInterface.isVirtual())); LOG.trace( MessageFormat.format( "Hardware address: %s%n", Arrays.toString(networkInterface.getHardwareAddress()))); LOG.trace(MessageFormat.format("MTU: %s%n", networkInterface.getMTU())); List<InterfaceAddress> interfaceAddresses = networkInterface.getInterfaceAddresses(); for (InterfaceAddress addr : interfaceAddresses) { LOG.trace(MessageFormat.format("InterfaceAddress: %s%n", addr.getAddress())); } LOG.trace(MessageFormat.format("%n", null)); Enumeration<NetworkInterface> subInterfaces = networkInterface.getSubInterfaces(); for (NetworkInterface aNetworkInterface : Collections.list(subInterfaces)) { LOG.trace(MessageFormat.format("%nSubInterface%n", null)); displayInterfaceInformation(aNetworkInterface); } LOG.trace(MessageFormat.format("%n", null)); }
/** * Returns a hash that should be consistent for any individual swarm client (as long as it has a * persistent IP) and should be unique to that client. * * @param remoteFsRoot the file system root should be part of the hash (to support multiple swarm * clients from the same machine) * @return our best effort at a consistent hash */ public static String hash(File remoteFsRoot) { StringBuilder buf = new StringBuilder(); try { buf.append(remoteFsRoot.getCanonicalPath()).append('\n'); } catch (IOException e) { buf.append(remoteFsRoot.getAbsolutePath()).append('\n'); } try { for (NetworkInterface ni : Collections.list(NetworkInterface.getNetworkInterfaces())) { for (InetAddress ia : Collections.list(ni.getInetAddresses())) { if (ia instanceof Inet4Address) { buf.append(ia.getHostAddress()).append('\n'); } else if (ia instanceof Inet6Address) { buf.append(ia.getHostAddress()).append('\n'); } } byte[] hardwareAddress = ni.getHardwareAddress(); if (hardwareAddress != null) { buf.append(Arrays.toString(hardwareAddress)); } } } catch (SocketException e) { // oh well we tried } return DigestUtils.md5Hex(buf.toString()).substring(0, 8); }
public Enumeration<String> getInitParameterNames() { Set<String> result = Sets.newLinkedHashSet(); result.addAll(Collections.list(filterConfig.getInitParameterNames())); result.addAll(Collections.list(filterConfig.getServletContext().getInitParameterNames())); return Iterators.asEnumeration(result.iterator()); }
@Override public Enumeration<URL> findResources(String name) throws IOException { final HashSet<URL> urls = new HashSet<>(); for (PomClassLoader cl : parents) { urls.addAll(Collections.list(cl.findResources(name))); } urls.addAll(Collections.list(super.findResources(name))); return Collections.enumeration(urls); }
private static List<TestFailure> createTestFailures( @NotNull InMemoryJavaGenerationHandler generationHandler, List<SModel> models) { List<TestFailure> testFailures = new ArrayList<TestFailure>(); junit.framework.TestResult result = new junit.framework.TestResult(); invokeTests(generationHandler, models, result, null); testFailures.addAll(Collections.list(result.failures())); testFailures.addAll(Collections.list(result.errors())); return testFailures; }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ public Enumeration<Option> listOptions() { Vector<Option> result = new Vector<Option>(); result.addElement( new Option("\tThe complexity constant C.\n" + "\t(default 1)", "C", 1, "-C <double>")); result.addElement( new Option( "\tWhether to 0=normalize/1=standardize/2=neither.\n" + "\t(default 0=normalize)", "N", 1, "-N")); result.addElement( new Option( "\tOptimizer class used for solving quadratic optimization problem\n" + "\t(default " + RegSMOImproved.class.getName() + ")", "I", 1, "-I <classname and parameters>")); result.addElement( new Option( "\tThe Kernel to use.\n" + "\t(default: weka.classifiers.functions.supportVector.PolyKernel)", "K", 1, "-K <classname and parameters>")); result.addAll(Collections.list(super.listOptions())); result.addElement( new Option( "", "", 0, "\nOptions specific to optimizer ('-I') " + getRegOptimizer().getClass().getName() + ":")); result.addAll(Collections.list(((OptionHandler) getRegOptimizer()).listOptions())); result.addElement( new Option( "", "", 0, "\nOptions specific to kernel ('-K') " + getKernel().getClass().getName() + ":")); result.addAll(Collections.list(((OptionHandler) getKernel()).listOptions())); return result.elements(); }
public DirectoryServer(int port) throws Exception { super("Directory Server", false); boolean connected = false; try { udp_socket = new DatagramSocket(port); System.out.println("The DirectoryServer UDP socket was bound to port: " + port); } catch (SocketException e) { udp_socket = new DatagramSocket(); System.out.println( "The DirectoryServer UDP socket was bound to port: " + udp_socket.getLocalPort()); } udp_socket.setSoTimeout(Server.TIMEOUT_Server); dsu = new DirectoryServerUDP(this); if (Application.db_dir == null) { db_dir = getDirDB(Application.CURRENT_DATABASE_DIR() + Application.DIRECTORY_FILE); Application.db_dir = db_dir; } else db_dir = Application.db_dir; do { try { if (port <= 0) port = Server.getRandomPort(); ss = new ServerSocket(port); connected = true; } catch (Exception e) { e.printStackTrace(); connected = false; port = Server.getRandomPort(); } } while (!connected); System.out.println("Got port: " + ss.getLocalPort()); /* System.out.println("Got net: "+ss.getInetAddress()); System.out.println("Got sock: "+ss.getLocalSocketAddress()); System.out.println("Got obj: "+ss); */ Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces(); for (NetworkInterface netint : Collections.list(nets)) { out.printf("Display name: %s\n", netint.getDisplayName()); out.printf( "Name: %s (loopback: %s; p2p:%s; up: %s, v: %s, m:%s)\n", netint.getName(), "" + netint.isLoopback(), "" + netint.isPointToPoint(), "" + netint.isUp(), "" + netint.isVirtual(), "" + netint.supportsMulticast()); Enumeration<InetAddress> inetAddresses = netint.getInetAddresses(); for (InetAddress inetAddress : Collections.list(inetAddresses)) { out.printf("inetAddress: %s\n", inetAddress); } } initAcceptedInets(); }
@Override public Enumeration<URL> getResources(final String name) throws IOException { if (!getState().isAvailable()) { return null; } if ("META-INF/services/javax.servlet.ServletContainerInitializer".equals(name)) { final Collection<URL> list = new ArrayList<>(Collections.list(super.getResources(name))); final Iterator<URL> it = list.iterator(); while (it.hasNext()) { final URL next = it.next(); final File file = Files.toFile(next); if (!file.isFile() && NewLoaderLogic.skip(next)) { it.remove(); } } return Collections.enumeration(list); } if ("META-INF/services/javax.websocket.ContainerProvider".equals(name)) { final Collection<URL> list = new ArrayList<>(Collections.list(super.getResources(name))); final Iterator<URL> it = list.iterator(); while (it.hasNext()) { final URL next = it.next(); final File file = Files.toFile(next); if (!file.isFile() && NewLoaderLogic.skip(next)) { it.remove(); } } return Collections.enumeration(list); } if ("META-INF/faces-config.xml".equals(name)) { // mojarra workaround try { if (WebBeansContext.currentInstance() == null && Boolean.parseBoolean( SystemInstance.get().getProperty("tomee.jsf.ignore-owb", "true"))) { final Collection<URL> list = new HashSet<>(Collections.list(super.getResources(name))); final Iterator<URL> it = list.iterator(); while (it.hasNext()) { final String fileName = Files.toFile(it.next()).getName(); if (fileName.startsWith("openwebbeans-" /*jsf|el22*/) && fileName.endsWith(".jar")) { it.remove(); } } return Collections.enumeration(list); } } catch (final Throwable th) { // no-op } } return URLClassLoaderFirst.filterResources(name, super.getResources(name)); }
public String detectPPP() { try { List<String> linkPPP = new ArrayList<String>(); List<String> linkDSL = new ArrayList<String>(); Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces(); // System.out.println("NETS VALUES"+" "+nets); // System.out.println("INITIALY VALUES"+" "+linkPPP); for (NetworkInterface netInf : Collections.list(nets)) { // System.out.println("netInf VALUES"+" "+netInf); if (!netInf.isLoopback()) { if (netInf.isPointToPoint()) { // System.out.println("in point to point"); // System.out.println("netInf VALUES"+" "+netInf); Enumeration<InetAddress> inetAdd = netInf.getInetAddresses(); // System.out.println("inetAdd VALUES"+" "+inetAdd); for (InetAddress inet : Collections.list(inetAdd)) { // System.out.println("inet vales in the ineer loop"+" "+inet); // System.out.println("linkPPP vales before add in the ineer loop"+" "+linkPPP); linkPPP.add(inet.getHostAddress()); // // System.out.println("linkPPP vales after add in the ineer loop"+" "+linkPPP); // System.out.println("IP:"+" "+inet.getHostAddress()); } } else { Enumeration<InetAddress> inetAdd = netInf.getInetAddresses(); for (InetAddress inet : Collections.list(inetAdd)) { linkDSL.add(inet.getHostAddress()); } } } } // System.out.println("FINAL VALUE of linkPPP"+" "+linkPPP.get(0)); // System.out.println("FINAL VALUES DSL"+" "+linkDSL); int i = linkPPP.size(); if (i != 0) { // System.out.println("linkPPP"+" "+linkPPP.get(i-1)); return linkPPP.get(i - 1) + ",y"; // return linkPPP.get(0)+",y"; } else if (linkDSL.size() != 0) return linkDSL.get(i - 1) + ",n"; // return linkDSL.get(0)+",n"; else return "127.0.0.1,n"; } catch (SocketException e) { // e.printStackTrace(); System.err.println("exception in "); } return "127.0.0.1,n"; }
private List<String> getServerInterfaces() { List<String> bindInterfaces = new ArrayList<String>(); String interfaceName = JiveGlobals.getXMLProperty("network.interface"); String bindInterface = null; if (interfaceName != null) { if (interfaceName.trim().length() > 0) { bindInterface = interfaceName; } } int adminPort = JiveGlobals.getXMLProperty("adminConsole.port", 9090); int adminSecurePort = JiveGlobals.getXMLProperty("adminConsole.securePort", 9091); if (bindInterface == null) { try { Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces(); for (NetworkInterface netInterface : Collections.list(nets)) { Enumeration<InetAddress> addresses = netInterface.getInetAddresses(); for (InetAddress address : Collections.list(addresses)) { if ("127.0.0.1".equals(address.getHostAddress())) { continue; } if (address.getHostAddress().startsWith("0.")) { continue; } Socket socket = new Socket(); InetSocketAddress remoteAddress = new InetSocketAddress(address, adminPort > 0 ? adminPort : adminSecurePort); try { socket.connect(remoteAddress); bindInterfaces.add(address.getHostAddress()); break; } catch (IOException e) { // Ignore this address. Let's hope there is more addresses to validate } } } } catch (SocketException e) { // We failed to discover a valid IP address where the admin console is running return null; } } else { bindInterfaces.add(bindInterface); } return bindInterfaces; }
private DatagramSocket sendDiscoveryBroadcast() throws Exception { final Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces(); for (NetworkInterface networkInterface : Collections.list(nets)) { final Enumeration<InetAddress> addresses = networkInterface.getInetAddresses(); for (InetAddress interfaceAddress : Collections.list(addresses)) { if (!interfaceAddress.isLoopbackAddress() && interfaceAddress instanceof Inet4Address) { return sendDiscoveryBroadcast(interfaceAddress); } } } throw new Exception("no service found"); }
private static InetAddress getLinkLocalAddress(String networkInterfaceName) throws SocketException { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); for (NetworkInterface networkInterface : Collections.list(networkInterfaces)) { if (networkInterfaceName == null || networkInterfaceName.equals(networkInterface.getName())) { Enumeration<InetAddress> ips = networkInterface.getInetAddresses(); for (InetAddress ip : Collections.list(ips)) { if (ip.isLinkLocalAddress()) { return ip; } } } } return null; }
public static Optional<InetAddress> getLocalAddress() { try { List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { List<InetAddress> addrs = Collections.list(intf.getInetAddresses()); for (InetAddress addr : addrs) { if (!addr.isLoopbackAddress() && addr instanceof Inet4Address) { return Optional.fromNullable(addr); } } } return Optional.absent(); } catch (Exception ex) { return Optional.absent(); } }
@Override public Enumeration<URL> getResources(String name) throws IOException { List<URL> urls = new ArrayList<URL>(); for (ClassLoader classLoader : getClassLoaders()) { urls.addAll(Collections.list(_getResources(classLoader, name))); } ClassLoader parentClassLoader = _parentClassLoaderReference.get(); if (parentClassLoader != null) { urls.addAll(Collections.list(_getResources(parentClassLoader, name))); } return Collections.enumeration(urls); }
static { try { InetAddress addr = InetAddress.getLocalHost(); HOST_NAME = addr.getHostName(); Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces(); for (NetworkInterface netint : Collections.list(nets)) { if (null != netint.getHardwareAddress()) { List<InterfaceAddress> list = netint.getInterfaceAddresses(); for (InterfaceAddress interfaceAddress : list) { InetAddress ip = interfaceAddress.getAddress(); if (ip instanceof Inet4Address) { HOST_IP += interfaceAddress.getAddress().toString(); } } } } HOST_IP = HOST_IP.replaceAll("null", ""); } catch (Exception e) { System.out.println("获取服务器IP出错"); } try { osmxb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); TotalMemorySize = osmxb.getTotalPhysicalMemorySize() / kb; } catch (Exception e) { System.out.println("获取系统信息失败"); e.printStackTrace(); } }
public static <E, F> void addRange(Dictionary<E, F> destino, Dictionary<E, F> valores) { List<E> keys = Collections.list(valores.keys()); for (E key : keys) { destino.put(key, valores.get(key)); } }
@Override public Enumeration getHeaders(String name) { ArrayList list = new ArrayList<String>(); // Never override the parent Request if (!name.equalsIgnoreCase("content-type")) { list = Collections.list(b.request.getHeaders(name)); } if (name.equalsIgnoreCase("content-type")) { String s = getContentType(); if (s != null) { list.add(s); } } else { if (b.headers.get(name) != null) { list.add(b.headers.get(name)); } if (isNotNoOps()) { if (list.size() == 0 && name.startsWith(X_ATMOSPHERE)) { if (attributeWithoutException(b.request, name) != null) { list.add(attributeWithoutException(b.request, name)); } } } } return Collections.enumeration(list); }
static void dumpToFile( String name1, String name2, OutputStream ostream, Hashtable<String, PkgEntry> tbl1, Hashtable<String, PkgEntry> tbl2) { List<String> keyList = new ArrayList<String>(); for (String x : Collections.list(tbl1.keys())) { keyList.add(x); } Collections.sort(keyList); PrintWriter pw = null; pw = new PrintWriter(new OutputStreamWriter(ostream)); pw.printf("\t%s\t%s\n", name1, name2); long sum1 = 0L; long sum2 = 0L; for (String x : keyList) { pw.printf("%s\t%s\t%s\n", x, tbl1.get(x).getSize() / 1024, tbl2.get(x).getSize() / 1024); sum1 += tbl1.get(x).getSize(); sum2 += tbl2.get(x).getSize(); } pw.printf("Total\t%s\t%s\n", sum1 / 1024, sum2 / 1024); pw.flush(); }
public static void load(Properties properties, String s) throws IOException { if (Validator.isNotNull(s)) { s = UnicodeFormatter.toString(s); s = StringUtil.replace(s, "\\u003d", "="); s = StringUtil.replace(s, "\\u000a", "\n"); s = StringUtil.replace(s, "\\u0021", "!"); s = StringUtil.replace(s, "\\u0023", "#"); s = StringUtil.replace(s, "\\u0020", " "); s = StringUtil.replace(s, "\\u005c", "\\"); properties.load(new UnsyncByteArrayInputStream(s.getBytes())); List<String> propertyNames = Collections.list((Enumeration<String>) properties.propertyNames()); for (int i = 0; i < propertyNames.size(); i++) { String key = propertyNames.get(i); String value = properties.getProperty(key); // Trim values because it may leave a trailing \r in certain // Windows environments. This is a known case for loading SQL // scripts in SQL Server. if (value != null) { value = value.trim(); properties.setProperty(key, value); } } } }
static ArrayList<String> getZipFileEntryNames(ZipFile z) { ArrayList<String> out = new ArrayList<String>(); for (ZipEntry ze : Collections.list(z.entries())) { out.add(ze.getName()); } return out; }
/** * Copy the given Enumeration into a String array. The Enumeration must contain String elements * only. * * @param enumeration the Enumeration to copy * @return the String array ({@code null} if the passed-in Enumeration was {@code null}) */ public static String[] toStringArray(Enumeration<String> enumeration) { if (enumeration == null) { return null; } List<String> list = Collections.list(enumeration); return list.toArray(new String[list.size()]); }
protected boolean jarUpToDate(String source, String target, boolean verbose) { JarFile targetJar, sourceJar; try { targetJar = new JarFile(target); } catch (IOException e) { if (verbose) err.println(target + " does not exist yet"); return false; } try { sourceJar = new JarFile(source); } catch (IOException e) { return true; } for (JarEntry entry : Collections.list(sourceJar.entries())) { JarEntry other = (JarEntry) targetJar.getEntry(entry.getName()); if (other == null) { if (verbose) err.println(target + " lacks the file " + entry.getName()); return false; } if (entry.getTime() > other.getTime()) { if (verbose) err.println(target + " is not " + "up-to-date because of " + entry.getName()); return false; } } try { targetJar.close(); sourceJar.close(); } catch (IOException e) { } return true; }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration<Option> listOptions() { Vector<Option> newVector = new Vector<Option>(2); newVector.addElement( new Option( "\tSkips the determination of sizes (train/test/clusterer)\n" + "\t(default: sizes are determined)", "no-size", 0, "-no-size")); newVector.addElement( new Option( "\tThe full class name of the density based clusterer.\n" + "\teg: weka.clusterers.EM", "W", 1, "-W <class name>")); if ((m_clusterer != null) && (m_clusterer instanceof OptionHandler)) { newVector.addElement( new Option( "", "", 0, "\nOptions specific to clusterer " + m_clusterer.getClass().getName() + ":")); newVector.addAll(Collections.list(((OptionHandler) m_clusterer).listOptions())); } return newVector.elements(); }