本文整理汇总了Java中org.springframework.core.io.FileSystemResource.exists方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystemResource.exists方法的具体用法?Java FileSystemResource.exists怎么用?Java FileSystemResource.exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.io.FileSystemResource
的用法示例。
在下文中一共展示了FileSystemResource.exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClassOrSystemPath
import org.springframework.core.io.FileSystemResource; //导入方法依赖的package包/类
/**
* 获取文件的绝对路径,class查找和系统路径查找
*/
public static String getClassOrSystemPath(String path) {
ClassPathResource rs = new ClassPathResource(path);
FileSystemResource fr = new FileSystemResource(path);
if (rs.exists())
return FileUtils.class.getClassLoader().getResource(path).getFile();
if (fr.exists())
return fr.getPath();
return null;
}
示例2: findTest
import org.springframework.core.io.FileSystemResource; //导入方法依赖的package包/类
/**
* Finds test for given package, class and method name.
* @param project
* @param packageName
* @param className
* @param methodName
* @return
*/
public Test findTest(Project project, String packageName, String className, String methodName) {
final FileSystemResource sourceFile = new FileSystemResource(project.getJavaDirectory() + packageName.replace('.', File.separatorChar) + System.getProperty("file.separator") + className + ".java");
if (!sourceFile.exists()) {
throw new ApplicationRuntimeException("Unable to find test source file: " + packageName + "." + className + " in " + project.getJavaDirectory());
}
Optional<Test> test = testProviders.parallelStream()
.flatMap(provider -> provider.findTests(project, Collections.singletonList(sourceFile.getFile())).stream())
.filter(candidate -> methodName == null || methodName.equals(candidate.getMethodName()))
.findFirst();
if (test.isPresent()) {
return test.get();
} else {
throw new ApplicationRuntimeException("Unable to find test: " + packageName + "." + className + "#" + methodName);
}
}
示例3: getTestResultsFile
import org.springframework.core.io.FileSystemResource; //导入方法依赖的package包/类
/**
* Access file resource representing the TestNG results file.
* @param activeProject
* @return
*/
private Resource getTestResultsFile(Project activeProject) {
FileSystemResource testSuiteFile = new FileSystemResource(activeProject.getProjectHome() + "/target/failsafe-reports/TEST-TestSuite.xml");
if (testSuiteFile.exists()) {
return testSuiteFile;
}
List<File> testCaseFiles = FileUtils.findFiles(activeProject.getProjectHome() + "/target/failsafe-reports", Collections.singleton("/TEST-*.xml"));
if (!CollectionUtils.isEmpty(testCaseFiles)) {
return new FileSystemResource(testCaseFiles.get(0));
}
return testSuiteFile;
}