java.util.Collections.list()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中java.util.Collections.list()方法的一些代码示例,展示了Collections.list()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collections.list()方法的具体详情如下:
包路径:java.util.Collections
类名称:Collections
方法名:list

Collections.list介绍

[英]Returns an ArrayList with all the elements in the enumeration. The elements in the returned ArrayList are in the same order as in the enumeration.
[中]返回包含枚举中所有元素的ArrayList。返回的ArrayList中的元素的顺序与枚举中的相同。

代码示例

代码示例来源:origin: stackoverflow.com

List<Logger> loggers = Collections.<Logger>list(LogManager.getCurrentLoggers());
loggers.add(LogManager.getRootLogger());
for ( Logger logger : loggers ) {
  logger.setLevel(Level.OFF);
}

代码示例来源:origin: org.apache.ant/ant

for (final String cur : Collections.list(target.getDependencies())) {
  final String m = state.get(cur);
  if (m == null) {
ret.addElement(target);

代码示例来源:origin: org.apache.ant/ant

Set<String> toAnalyze = new HashSet<>(Collections.list(getRootClasses()));
Set<String> analyzedDeps = new HashSet<>();
files.addAll(containers);
classes.removeAllElements();
classes.addAll(dependencies);

代码示例来源:origin: org.apache.ant/ant

v.add("#PCDATA");
  v.add(TASKS);
v.addAll(Collections.list(ih.getNestedElements()));
sb.append(String.format("<!ATTLIST %s%n          id ID #IMPLIED", name));
for (final String attrName : Collections.list(ih.getAttributes())) {
  if ("id".equals(attrName)) {
    continue;

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * 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>();
 newVector.addElement(new Option("\tOutput additional statistics.",
  "additional-stats", 0, "-additional-stats"));
 newVector.addAll(Collections.list(super.listOptions()));
 return newVector.elements();
}

代码示例来源:origin: elastic/elasticsearch-hadoop

/** Returns all global scope addresses for interfaces that are up. */
  static InetAddress[] getGlobalInterfaces() throws SocketException {
    List<InetAddress> list = new ArrayList<InetAddress> ();
    for (NetworkInterface intf : getInterfaces()) {
      if (intf.isUp()) {
        for (InetAddress address : Collections.list(intf.getInetAddresses())) {
          if (address.isLoopbackAddress() == false &&
              address.isSiteLocalAddress() == false &&
              address.isLinkLocalAddress() == false) {
            list.add(address);
          }
        }
      }
    }
    return list.toArray(new InetAddress[list.size()]);
  }
}

代码示例来源:origin: apache/nifi

serverConnectors.add(serverConnector);
} else {
  }).filter(Objects::nonNull).flatMap(iface -> Collections.list(iface.getInetAddresses()).stream())
      .map(inetAddress -> {
        final ServerConnector serverConnector = serverConnectorCreator.create(server, configuration);

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Returns an enumeration describing the available options.
 * 
 * @return an enumeration of all the available options.
 */
@Override
public Enumeration<Option> listOptions() {
 Vector<Option> result = new Vector<Option>();
 result.addElement(new Option("\tThe class index\n" + "\t(default: last)",
  "c", 1, "-c <class index>"));
 result.addAll(Collections.list(super.listOptions()));
 return result.elements();
}

代码示例来源:origin: org.javassist/javassist

JarClassPath(String pathname) throws NotFoundException {
  JarFile jarfile = null;
  try {
    jarfile = new JarFile(pathname);
    jarfileEntries = new ArrayList<String>();
    for (JarEntry je:Collections.list(jarfile.entries()))
      if (je.getName().endsWith(".class"))
        jarfileEntries.add(je.getName());
    jarfileURL = new File(pathname).getCanonicalFile()
        .toURI().toURL().toString();
    return;
  } catch (IOException e) {}
  finally {
    if (null != jarfile)
      try {
        jarfile.close();
      } catch (IOException e) {}
  }
  throw new NotFoundException(pathname);
}

代码示例来源:origin: apache/tika

List<URL> extensionURLs = Collections.list(
    classLoader.getResources(classPrefix+extensionFilePath));
urls.add(coreURL);
urls.addAll(extensionURLs);
        "Specified custom mimetypes file not found: " + customMimesPath);
  URL externalURL = externalFile.toURI().toURL();
  urls.add(externalURL);

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Returns an enumeration describing the available options.
 * 
 * @return an enumeration of all the available options.
 */
@Override
public Enumeration<Option> listOptions() {
 Vector<Option> result = new Vector<Option>();
 result.addElement(new Option("The class index", "c", 1,
  "-c <the class index>"));
 result.addAll(Collections.list(super.listOptions()));
 return result.elements();
}

代码示例来源:origin: jooby-project/jooby

private static List<URI> expandPath(final ClassLoader loader, final String pattern) {
 List<URI> result = new ArrayList<>();
 File file = new File(pattern);
 if (file.exists()) {
  result.add(file.toURI());
 }
 Try.run(() -> Collections.list(loader.getResources(pattern))
   .stream()
   .map(it -> Try.apply(it::toURI).get())
   .forEach(result::add));
 return result;
}

代码示例来源:origin: com.github.adminfaces/admin-template

/**
 * Load, merge and return all <code>web.xml</code> and <code>web-fragment.xml</code> files found in the classpath
 * into a single {@link Document}.
 */
private static Document loadWebXml(ServletContext context) throws IOException, SAXException {
  List<URL> webXmlURLs = new ArrayList<>();
  webXmlURLs.add(context.getResource(WEB_XML));
  webXmlURLs.addAll(Collections.list(Thread.currentThread().getContextClassLoader().getResources(WEB_FRAGMENT_XML)));
  return createDocument(webXmlURLs);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * 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>();
 newVector.addElement(new Option("\tSet base of the expansion constant\n"
  + "\t(default = 1.3).", "B", 1, "-B <value>"));
 newVector.addAll(Collections.list(super.listOptions()));
 return newVector.elements();
}

代码示例来源:origin: scouter-project/scouter

JarClassPath(String pathname) throws NotFoundException {
  JarFile jarfile = null;
  try {
    jarfile = new JarFile(pathname);
    jarfileEntries = new ArrayList<String>();
    for (JarEntry je:Collections.list(jarfile.entries()))
      if (je.getName().endsWith(".class"))
        jarfileEntries.add(je.getName());
    jarfileURL = new File(pathname).getCanonicalFile()
        .toURI().toURL().toString();
    return;
  } catch (IOException e) {}
  finally {
    if (null != jarfile)
      try {
        jarfile.close();
      } catch (IOException e) {}
  }
  throw new NotFoundException(pathname);
}

代码示例来源:origin: omnifaces/omnifaces

/**
 * Load, merge and return all <code>web.xml</code> and <code>web-fragment.xml</code> files found in the classpath
 * into a single {@link Document}.
 */
private static Document loadWebXml(ServletContext context) throws IOException, SAXException {
  List<URL> webXmlURLs = new ArrayList<>();
  webXmlURLs.add(context.getResource(WEB_XML));
  webXmlURLs.addAll(Collections.list(Thread.currentThread().getContextClassLoader().getResources(WEB_FRAGMENT_XML)));
  return createDocument(webXmlURLs);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Returns an enumeration describing the available options
 * 
 * @return an enumeration of all the available options
 */
@Override
public Enumeration<Option> listOptions() {
 Vector<Option> result = new Vector<Option>();
 result.addElement(new Option("\tThe epsilon for round-off error.\n"
  + "\t(default 1.0e-12)", "P", 1, "-P <double>"));
 result.addAll(Collections.list(super.listOptions()));
 return result.elements();
}

代码示例来源:origin: google/j2objc

for (URL resource : Collections.list(resources)) {
  InputStream in = null;
  try {
      String name = stripCommentAndWhitespace(line);
      if (name.length() != 0) {
        result.add(service.cast(loader.loadClass(name).newInstance()));

代码示例来源:origin: org.milyn/milyn-commons

@Override
  protected Enumeration<URL> findResources(String resName) throws IOException {
    List<URL> resources = new ArrayList<URL>();
    URL resource = archive.getEntryURL(resName);

    if (resource != null) {
      resources.add(resource);
    }

    Enumeration<URL> parentResource = getParent().getResources(resName);
    resources.addAll(Collections.list(parentResource));

    return Collections.enumeration(resources);
  }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Returns an enumeration describing the available options.
 * 
 * @return an enumeration of all the available options.
 */
@Override
public Enumeration<Option> listOptions() {
 Vector<Option> result = new Vector<Option>();
 result.addElement(new Option("\tRandom number seed.\n" + "\t(default "
  + m_SeedDefault + ")", "S", 1, "-S <num>"));
 result.addAll(Collections.list(super.listOptions()));
 return result.elements();
}

相关文章

微信公众号

最新文章

更多

Collections类方法