本文整理汇总了Java中gov.nih.nci.cagrid.common.Utils.recursiveListFiles方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.recursiveListFiles方法的具体用法?Java Utils.recursiveListFiles怎么用?Java Utils.recursiveListFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gov.nih.nci.cagrid.common.Utils
的用法示例。
在下文中一共展示了Utils.recursiveListFiles方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listHistoryFilesByDate
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
private List<File> listHistoryFilesByDate() {
final File historyDir = getHistoryDirectory();
List<File> historyFiles = Utils.recursiveListFiles(historyDir, new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().endsWith(".xml") || pathname.isDirectory();
}
});
Comparator<File> comp = new Comparator<File>() {
public int compare(File o1, File o2) {
int val = 0;
try {
String rel1 = Utils.getRelativePath(historyDir, o1);
String rel2 = Utils.getRelativePath(historyDir, o2);
val = rel1.compareTo(rel2);
} catch (Exception ex) {
// uhoh
}
return val;
}
};
Collections.sort(historyFiles, comp);
return historyFiles;
}
示例2: getDirectoryClassNames
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
/**
* Gets class names from the given directory of .class files
* @param directory
* @return
* A List of Class names
*/
private List<String> getDirectoryClassNames(File directory) {
List<File> classFiles = Utils.recursiveListFiles(directory, new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().toLowerCase().endsWith(CLASS_EXTSNSION);
}
});
List classNames = new ArrayList(classFiles.size());
int baseDirNameLength = directory.getAbsolutePath().length() + 1;
for (File classFile : classFiles) {
String rawName = classFile.getAbsolutePath();
rawName = rawName.substring(baseDirNameLength);
rawName = rawName.substring(0, rawName.length() - CLASS_EXTSNSION.length());
rawName = rawName.replace(File.separatorChar, '.');
classNames.add(rawName);
}
return classNames;
}
示例3: main
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
File base = new File("/Users/ervin/Projects/caGrid/caGrid-1_5_release/Software/core");
try {
List<File> classpaths = Utils.recursiveListFiles(base, new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.getName().equals(".classpath");
}
});
for (File f : classpaths) {
if (f.isFile()) {
System.out.println("Editing " + f.getAbsolutePath());
FileInputStream fis = new FileInputStream(f);
StringBuffer buf = Utils.inputStreamToStringBuffer(fis);
fis.close();
String edited = buf.toString().replace("GT4_LOCATION", "GT4_SHA2_LOCATION");
Utils.stringBufferToFile(new StringBuffer(edited), f);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例4: listHistoryFilesByDate
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
private List<File> listHistoryFilesByDate() {
final File historyDir = getHistoryDirectory();
List<File> historyFiles = Utils.recursiveListFiles(historyDir, new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().endsWith(".xml") || pathname.isDirectory();
}
});
Comparator<File> comp = new Comparator<File>() {
public int compare(File o1, File o2) {
int val = 0;
try {
String rel1 = Utils.getRelativePath(historyDir, o1);
String rel2 = Utils.getRelativePath(historyDir, o2);
val = rel1.compareTo(rel2);
} catch (Exception ex) {
// uhoh
}
return val;
}
};
Collections.sort(historyFiles, comp);
return historyFiles;
}
示例5: copyMetadataSchemas
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
private void copyMetadataSchemas(String schemaDir) throws Exception {
System.out.println("Copying schemas to " + schemaDir);
File extensionSchemaDir = new File(ExtensionsLoader.EXTENSIONS_DIRECTORY + File.separator
+ MetadataConstants.EXTENSION_NAME + File.separator + "schema");
List<File> schemaFiles = Utils.recursiveListFiles(extensionSchemaDir, new FileFilters.XSDFileFilter());
for (int i = 0; i < schemaFiles.size(); i++) {
File schemaFile = schemaFiles.get(i);
String subname = schemaFile.getCanonicalPath().substring(
extensionSchemaDir.getCanonicalPath().length() + File.separator.length());
copySchema(subname, schemaDir);
}
}
示例6: main
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
try {
MappingTool tool = new MappingTool();
File srcDir = new File("src/java/beans/dcql2");
List<File> files = Utils.recursiveListFiles(srcDir, new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().endsWith(".java");
}
});
for (File f : files) {
if (f.isFile() && !f.getName().startsWith("MappingDriver")) {
String path = Utils.getRelativePath(srcDir, f.getCanonicalFile());
path = path.substring(0, path.length() - 5);
String className = path.replace(File.separatorChar, '.');
System.out.println("Found " + className);
System.out.flush();
tool.addClass(className);
}
}
StringWriter writer = new StringWriter();
tool.write(writer);
String pretty = XMLUtilities.formatXML(writer.getBuffer().toString());
System.out.println(pretty);
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例7: copyDataServiceSchemas
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
private void copyDataServiceSchemas(ServiceInformation serviceInfo) throws CreationExtensionException {
// grab cql query and result set schemas and move them into the
// service's directory
String schemaDir = getServiceSchemaDir(serviceInfo);
log.debug("Copying schemas to " + schemaDir);
FileFilter dataXsdFilter = new FileFilter() {
public boolean accept(File pathname) {
if (pathname.isDirectory() || pathname.getName().endsWith(".xsd")) {
return !pathname.getName().equals(WsEnumConstants.ENUMERATION_WSDL_NAME)
&& !pathname.getName().equals(WsEnumConstants.ENUMERATION_XSD_NAME)
&& !pathname.getName().equals(WsEnumConstants.ADDRESSING_XSD_NAME);
}
return false;
}
};
// get schemas for data services
File baseSchemaDir = new File(ExtensionsLoader.getInstance().getExtensionsDir(),
"data" + File.separator + "schema");
File dataSchemaDir = new File(baseSchemaDir, "Data");
List<File> dataSchemaFiles = Utils.recursiveListFiles(dataSchemaDir, dataXsdFilter);
// also copy the WSDLs for data services
dataSchemaFiles.add(new File(dataSchemaDir, "DataService.wsdl"));
dataSchemaFiles.add(new File(dataSchemaDir, "Cql2DataService.wsdl"));
try {
for (File schemaFile : dataSchemaFiles) {
String subname = schemaFile.getAbsolutePath().substring(
dataSchemaDir.getAbsolutePath().length() + File.separator.length());
File schemaOut = new File(schemaDir + File.separator + subname);
Utils.copyFile(schemaFile, schemaOut);
}
} catch (Exception ex) {
throw new CreationExtensionException(
"Error copying data service schemas: " + ex.getMessage(), ex);
}
}
示例8: countXmlDocsInHistory
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
private int countXmlDocsInHistory() {
List<File> history = Utils.recursiveListFiles(tempHistoryDir, new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().endsWith(".xml");
}
});
int count = 0;
for (File f : history) {
if (f.isFile() && f.getName().endsWith(".xml")) {
count++;
}
}
return count;
}
示例9: getAvailableAuditorClasses
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public static List<Class> getAvailableAuditorClasses(File libDir) throws MalformedURLException, IOException {
// list jars from the lib dir as URLs
List jarFiles = Utils.recursiveListFiles(libDir, new FileFilters.JarFileFilter());
List<URL> jarUrls = new LinkedList<URL>();
for (int i = 0; i < jarFiles.size(); i++) {
File jarFile = (File) jarFiles.get(i);
if (jarFile.isFile()) {
jarUrls.add(jarFile.toURL());
}
}
URL[] urlArray = new URL[jarUrls.size()];
jarUrls.toArray(urlArray);
System.out.println("Looking for data service auditor subclasses");
// load all subclasses of DataServiceAuditor
List<Class> subclasses = new LinkedList<Class>();
for (int i = 0; i < jarFiles.size(); i++) {
// loader created each time because
// iterating over many classes clogs up the cache in the loader
ClassLoader loader = new URLClassLoader(urlArray);
JarFile jar = new JarFile((File) jarFiles.get(i));
Enumeration jarEntries = jar.entries();
while (jarEntries.hasMoreElements()) {
JarEntry entry = (JarEntry) jarEntries.nextElement();
String name = entry.getName();
if (name.endsWith(".class")) {
name = name.replace('/', '.');
name = name.substring(0, name.length() - 6);
Class loadedClass = null;
try {
loadedClass = loader.loadClass(name);
} catch (Throwable e) {
// theres a lot of these...
// System.err.println("Error loading class (" + name
// + "):" + e.getMessage());
}
if (loadedClass != null && DataServiceAuditor.class.isAssignableFrom(loadedClass)
&& !DataServiceAuditor.class.getName().equals(loadedClass.getName())) {
subclasses.add(loadedClass);
}
}
}
loader = null;
jar.close();
}
return subclasses;
}