本文整理了Java中org.scijava.util.FileUtils.listContents()
方法的一些代码示例,展示了FileUtils.listContents()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.listContents()
方法的具体详情如下:
包路径:org.scijava.util.FileUtils
类名称:FileUtils
方法名:listContents
[英]Recursively lists the contents of the referenced directory. Directories are excluded from the result. Supported protocols include file and jar.
[中]递归列出引用目录的内容。从结果中排除目录。支持的协议包括文件和jar。
代码示例来源:origin: scijava/scijava-common
/**
* Recursively lists the contents of the referenced directory. Directories are
* excluded from the result. Supported protocols include {@code file} and
* {@code jar}.
*
* @param directory The directory whose contents should be listed.
* @return A collection of {@link URL}s representing the directory's contents.
* @see #listContents(URL, boolean, boolean)
*/
public static Collection<URL> listContents(final URL directory) {
return listContents(directory, true, true);
}
代码示例来源:origin: org.scijava/scijava-common
/**
* Recursively lists the contents of the referenced directory. Directories are
* excluded from the result. Supported protocols include {@code file} and
* {@code jar}.
*
* @param directory The directory whose contents should be listed.
* @return A collection of {@link URL}s representing the directory's contents.
* @see #listContents(URL, boolean, boolean)
*/
public static Collection<URL> listContents(final URL directory) {
return listContents(directory, true, true);
}
代码示例来源:origin: org.scijava/scijava-common
/** Scans for annotations files in every resource on the classpath. */
public Set<String> getAnnotationFiles() throws IOException {
final HashSet<String> files = new HashSet<>();
for (final String prefix : new String[] { PREFIX, LEGACY_PREFIX }) {
final Enumeration<URL> directories =
Thread.currentThread().getContextClassLoader().getResources(prefix);
while (directories.hasMoreElements()) {
final URL url = directories.nextElement();
for (final URL annotationIndexURL : FileUtils.listContents(url)) {
String string = annotationIndexURL.toString();
if (string.endsWith("/")) {
continue;
}
final int length = string.length();
add(files, PREFIX +
string.substring(string.lastIndexOf('/', length - 1) + 1, length));
}
}
}
return files;
}
代码示例来源:origin: scijava/scijava-common
/** Scans for annotations files in every resource on the classpath. */
public Set<String> getAnnotationFiles() throws IOException {
final HashSet<String> files = new HashSet<>();
for (final String prefix : new String[] { PREFIX, LEGACY_PREFIX }) {
final Enumeration<URL> directories =
Thread.currentThread().getContextClassLoader().getResources(prefix);
while (directories.hasMoreElements()) {
final URL url = directories.nextElement();
for (final URL annotationIndexURL : FileUtils.listContents(url)) {
String string = annotationIndexURL.toString();
if (string.endsWith("/")) {
continue;
}
final int length = string.length();
add(files, PREFIX +
string.substring(string.lastIndexOf('/', length - 1) + 1, length));
}
}
}
return files;
}
代码示例来源:origin: net.imagej/imagej-common
private static void getResources(final Pattern pattern,
final Map<String, URL> result, final URL base)
{
final String prefix = urlPath(base);
if (prefix == null) return; // unsupported base URL
for (final URL url : FileUtils.listContents(base)) {
final String s = urlPath(url);
if (s == null || !s.startsWith(prefix)) continue;
if (pattern == null || pattern.matcher(s).matches()) {
// this resource matches the pattern
final String key = urlPath(s.substring(prefix.length()));
if (key != null) result.put(key, url);
}
}
}
代码示例来源:origin: scijava/scijava-common
/** Helper method of {@link #findResources(String, Iterable)}. */
private static void getResources(final Pattern pattern,
final Map<String, URL> result, final URL base)
{
final String prefix = urlPath(base);
if (prefix == null) return; // unsupported base URL
for (final URL url : FileUtils.listContents(base)) {
final String s = urlPath(url);
if (s == null || !s.startsWith(prefix)) continue;
if (pattern == null || pattern.matcher(s).matches()) {
// this resource matches the pattern
final String key = urlPath(s.substring(prefix.length()));
if (key != null) result.put(key, url);
}
}
}
代码示例来源:origin: org.scijava/scijava-common
/** Helper method of {@link #findResources(String, Iterable)}. */
private static void getResources(final Pattern pattern,
final Map<String, URL> result, final URL base)
{
final String prefix = urlPath(base);
if (prefix == null) return; // unsupported base URL
for (final URL url : FileUtils.listContents(base)) {
final String s = urlPath(url);
if (s == null || !s.startsWith(prefix)) continue;
if (pattern == null || pattern.matcher(s).matches()) {
// this resource matches the pattern
final String key = urlPath(s.substring(prefix.length()));
if (key != null) result.put(key, url);
}
}
}
代码示例来源:origin: org.scijava/scijava-common
for (final URL url : FileUtils.listContents(directories.nextElement())) {
final String urlString = url.toString();
if (urlString.endsWith("/")) {
代码示例来源:origin: scijava/scijava-common
for (final URL url : FileUtils.listContents(directories.nextElement())) {
final String urlString = url.toString();
if (urlString.endsWith("/")) {
代码示例来源:origin: scijava/scijava-common
for (final URL url : FileUtils.listContents(resource)) {
代码示例来源:origin: org.scijava/scijava-common
for (final URL url : FileUtils.listContents(resource)) {
代码示例来源:origin: net.imagej/imagej-legacy
for (final URL url : FileUtils.listContents(base)) {
final String path = url.toString().substring(baseLength);
if (!prefixPattern.matcher(path).matches()) {
代码示例来源:origin: net.imagej/imagej-legacy
for (final URL url : FileUtils.listContents(pomBase, true, true)) {
if (url.toExternalForm().endsWith("/pom.xml")) {
return new POM(url);
代码示例来源:origin: org.scijava/scijava-search
for (final URL url : FileUtils.listContents(pomBase, true, true)) {
if (url.toExternalForm().endsWith("/pom.xml")) {
return new POM(url);
代码示例来源:origin: scijava/scijava-common
for (final URL url : FileUtils.listContents(pomBase, true, true)) {
if (url.toExternalForm().endsWith("/pom.xml")) {
return new POM(url);
代码示例来源:origin: org.scijava/scijava-common
for (final URL url : FileUtils.listContents(pomBase, true, true)) {
if (url.toExternalForm().endsWith("/pom.xml")) {
return new POM(url);
代码示例来源:origin: scijava/scijava-common
Collection<URL> urls = FileUtils.listContents(nonExisting.toURI().toURL());
assertNotNull(urls);
assertEquals(0, urls.size());
final Collection<URL> setTT = FileUtils.listContents(url, true, true);
final URL[] listTT = setTT.toArray(new URL[setTT.size()]);
assertArrayEquals(new URL[] { helloURL, rockURL, foxURL, dogURL }, listTT);
final Collection<URL> setTF = FileUtils.listContents(url, true, false);
final URL[] listTF = setTF.toArray(new URL[setTF.size()]);
assertArrayEquals(
final Collection<URL> setFT = FileUtils.listContents(url, false, true);
final URL[] listFT = setFT.toArray(new URL[setFT.size()]);
assertArrayEquals(new URL[] { helloURL, rockURL }, listFT);
final Collection<URL> setFF = FileUtils.listContents(url, false, false);
final URL[] listFF = setFF.toArray(new URL[setFF.size()]);
assertArrayEquals(new URL[] { subSubURL, helloURL, rockURL }, listFF);
内容来源于网络,如有侵权,请联系作者删除!