本文整理匯總了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;
}