当前位置: 首页>>代码示例>>Java>>正文


Java Resource.isReadable方法代码示例

本文整理汇总了Java中org.springframework.core.io.Resource.isReadable方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.isReadable方法的具体用法?Java Resource.isReadable怎么用?Java Resource.isReadable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.core.io.Resource的用法示例。


在下文中一共展示了Resource.isReadable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadAsResource

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
@Override
public Resource loadAsResource(String filename) {
    try {
        Path file = load(filename);
        Resource resource = new UrlResource(file.toUri());
        if(resource.exists() || resource.isReadable()) {
            return resource;
        }
        else {
            throw new StorageFileNotFoundException("Could not read file: " + filename);

        }
    } catch (MalformedURLException e) {
        throw new StorageFileNotFoundException("Could not read file: " + filename, e);
    }
}
 
开发者ID:Yuiffy,项目名称:file-download-upload-zip-demo,代码行数:17,代码来源:FileSystemStorageService.java

示例2: getResource

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
@Override
protected Resource getResource(String resourcePath, Resource location) throws IOException {
    Resource resource = location.createRelative(resourcePath);
    if (resource.exists() && resource.isReadable()) {
        return resource;
    }
    if (getApiPath() != null && ("/" + resourcePath).startsWith(getApiPath())) {
        return null;
    }
    if(getApiPublicPath() != null && ("/" + resourcePath).startsWith(getApiPublicPath())) {
        return null;
    }

    LoggerFactory.getLogger(getClass()).info("Routing /" + resourcePath + " to /index.html");
    resource = location.createRelative("/WEB-INF/app/" + resourcePath);

    LoggerFactory.getLogger(getClass()).info("Routing to " + resource);
    if (resource.exists() && resource.isReadable()) {
        return resource;
    }
    return null;
}
 
开发者ID:howma03,项目名称:sporticus,代码行数:23,代码来源:ConfigurationWeb.java

示例3: loadAsResource

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
@Override
public Resource loadAsResource(String filename) {
    try {
        Path file = this.rootLocation.resolve(filename);
        Resource resource = new UrlResource(file.toUri());
        if (resource.exists() || resource.isReadable()) {
            return resource;
        } else {
            throw new UploadFileNotFoundException(
                    "Could not read file: " + filename);

        }
    } catch (MalformedURLException e) {
        throw new UploadFileNotFoundException("Could not read file: " + filename, e);
    }
}
 
开发者ID:itdl,项目名称:AIweb,代码行数:17,代码来源:UploadKaServiceImpl.java

示例4: loadClassName

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * 加载资源,根据resource获取className
 *
 * @param metadataReaderFactory spring中用来读取resource为class的工具
 * @param resource              这里的资源就是一个Class
 * @throws IOException
 */
private static String loadClassName(MetadataReaderFactory metadataReaderFactory, Resource resource)
		throws IOException
{
	try
	{
		if (resource.isReadable())
		{
			MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
			if (metadataReader != null)
			{
				return metadataReader.getClassMetadata().getClassName();
			}
		}
	}
	catch (Exception e)
	{
		LOG.error("根据resource获取类名称失败", e);
	}
	return null;
}
 
开发者ID:netease-lede,项目名称:rocketmq-easyclient,代码行数:28,代码来源:ScanPackage.java

示例5: findMyTypes

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
protected List<Class<?>> findMyTypes(String basePackage) throws IOException, ClassNotFoundException {
	ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
	MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resourcePatternResolver);

	List<Class<?>> candidates = new ArrayList<>();
	String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resolveBasePackage(basePackage)
	                           + "/" + "**/*.class";
	Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
	for (Resource resource : resources) {
		if (resource.isReadable()) {
			MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
			if (isCandidate(metadataReader)) {
				candidates.add(forName(metadataReader.getClassMetadata().getClassName()));
			}
		}
	}
	return candidates;
}
 
开发者ID:namics,项目名称:spring-batch-support,代码行数:19,代码来源:AutomaticJobRegistrarConfigurationSupport.java

示例6: getClassSet

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * 将符合条件的Bean以Class集合的形式返回
 * 
 * @return
 * @throws IOException
 * @throws ClassNotFoundException
 */
public Set<Class<?>> getClassSet() throws IOException, ClassNotFoundException {
	this.classSet.clear();
	if (!this.packagesList.isEmpty()) {
		for (String pkg : this.packagesList) {
			String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
					+ ClassUtils.convertClassNameToResourcePath(pkg) + RESOURCE_PATTERN;
			Resource[] resources = this.resourcePatternResolver.getResources(pattern);
			MetadataReaderFactory readerFactory = new CachingMetadataReaderFactory(this.resourcePatternResolver);
			for (Resource resource : resources) {
				if (resource.isReadable()) {
					MetadataReader reader = readerFactory.getMetadataReader(resource);
					String className = reader.getClassMetadata().getClassName();
					if (matchesEntityTypeFilter(reader, readerFactory)) {
						this.classSet.add(Class.forName(className));
					}
				}
			}
		}
	}
	return this.classSet;
}
 
开发者ID:jweixin,项目名称:jwx,代码行数:29,代码来源:ClasspathPackageScanner.java

示例7: scan

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * 将符合条件的Bean以Class集合的形式返回
 * @throws Exception 异常
 * @return 类集合
 */
public Set<Class<?>> scan() throws Exception {
	Set<Class<?>> classSet = new HashSet<Class<?>>();
	if (!this.packagesList.isEmpty()) {
		for (String pkg : this.packagesList) {
			String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
					ClassUtils.convertClassNameToResourcePath(pkg) + RESOURCE_PATTERN;
			Resource[] resources = this.resourcePatternResolver.getResources(pattern);
			MetadataReaderFactory readerFactory = new CachingMetadataReaderFactory(this.resourcePatternResolver);
			for (Resource resource : resources) {
				if (resource.isReadable()) {
					MetadataReader reader = readerFactory.getMetadataReader(resource);
					String className = reader.getClassMetadata().getClassName();
					if (matchesEntityTypeFilter(reader, readerFactory)) {
						classSet.add(Class.forName(className));
					}
				}
			}
		}
	}
	return classSet;
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:27,代码来源:ClassScanner.java

示例8: loadClassName

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * 加载资源,根据resource获取className
 *
 * @param metadataReaderFactory
 *            spring中用来读取resource为class的工具
 * @param resource
 *            这里的资源就是一个Class
 * @throws IOException
 */
private static String loadClassName(MetadataReaderFactory metadataReaderFactory, Resource resource)
        throws IOException {
    try {
        if (resource.isReadable()) {
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            if (metadataReader != null) {
                return metadataReader.getClassMetadata().getClassName();
            }
        }
    }
    catch (Exception e) {
        log.error("根据resource获取类名称失败", e);
    }
    return null;
}
 
开发者ID:devpage,项目名称:sharding-quickstart,代码行数:25,代码来源:PackageUtil.java

示例9: loadAsResource

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
public Resource loadAsResource(String path) {
    Path filePath = Paths.get(properties.getUploadFileRootPath(), path);
    Resource resource = new FileSystemResource(filePath.toFile());
    if (resource.exists() || resource.isReadable()) {
        return resource;
    }
    else {
        throw new StorageException("Could not read file: " + path);
    }
}
 
开发者ID:spring-sprout,项目名称:osoon,代码行数:11,代码来源:UserFileService.java

示例10: getResourceInputStream

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
 * Retrieve the remote source's input stream to parse data.
 * @param resource the resource
 * @param entityId the entity id
 * @return the input stream
 * @throws IOException if stream cannot be read
 */
protected InputStream getResourceInputStream(final Resource resource, final String entityId) throws IOException {
    logger.debug("Locating metadata resource from input stream.");
    if (!resource.exists() || !resource.isReadable()) {
        throw new FileNotFoundException("Resource does not exist or is unreadable");
    }
    return resource.getInputStream();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:AbstractMetadataResolverAdapter.java

示例11: loadAsResource

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
public Resource loadAsResource(String filename) {
    try {
        String filePath = filename.substring(0, 2) + "/" + filename.substring(2);
        Resource resource = new UrlResource(Paths.get(storageDirectory, filePath).toUri());
        if(resource.exists() || resource.isReadable()) {
            return resource;
        } else {
            throw new RuntimeException("Could not read file: " + filename);

        }
    } catch (Exception e) {
        throw new RuntimeException("Could not read file: " + filename, e);
    }
}
 
开发者ID:myliang,项目名称:fish-admin,代码行数:15,代码来源:StorageService.java

示例12: loadAsResource

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
public Resource loadAsResource(String filename) {
    try {
        Path file = load(filename);
        Resource resource = new UrlResource(file.toUri());
        if(resource.exists() || resource.isReadable()) {
            return resource;
        }
        else {
            throw new SIIStemTechnicalException("Could not read file: " + filename);

        }
    } catch (MalformedURLException e) {
        throw new SIIStemTechnicalException("Could not read file: " + filename, e);
    }
}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:16,代码来源:FileSystemStorageService.java

示例13: loadResource

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
public Resource loadResource(String uuid) throws Exception {
    String filename = StringUtils.cleanPath(uuid);

    Resource resource = new UrlResource(storageDir.resolve(filename).toUri());
    if (resource.exists() || resource.isReadable()) {
        return resource;
    }
    else {
        throw new TusStorageException(filename);

    }
}
 
开发者ID:thomasooo,项目名称:spring-boot-tus,代码行数:13,代码来源:StorageServiceImpl.java

示例14: loadAsResource

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
@Override
public Resource loadAsResource(String filepath) {
    try {
        Path file = load(filepath);
        Resource resource = new UrlResource(file.toUri());
        if(resource.exists() || resource.isReadable()) {
            return resource;
        }else {
            throw new StorageFileNotFoundException("Couldn't read file: " + filepath);
        }
    } catch (MalformedURLException e) {
        throw new StorageFileNotFoundException("Couldn't read file: " + filepath);
    }
}
 
开发者ID:chaokunyang,项目名称:amanda,代码行数:15,代码来源:FileSystemStorageService.java

示例15: loadAsResource

import org.springframework.core.io.Resource; //导入方法依赖的package包/类
@Override
public Resource loadAsResource(String filename) {
    try {
        Path file = load(filename);
        Resource resource = new UrlResource(file.toUri());
        if (resource.exists() || resource.isReadable()) {
            return resource;
        } else {
            throw new StorageFileNotFoundException("Could not read chart: " + filename);

        }
    } catch (MalformedURLException e) {
        throw new StorageFileNotFoundException("Could not read chart: " + filename, e);
    }
}
 
开发者ID:robinhowlett,项目名称:handycapper,代码行数:16,代码来源:FileSystemStorageService.java


注:本文中的org.springframework.core.io.Resource.isReadable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。