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


Java StringUtils.applyRelativePath方法代码示例

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


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

示例1: storeResource

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * 保存Resource到持久化,这个实现中是文件
 *
 * @param mediaEntity
 * @return File
 */
@Override
public Resource storeResource(MediaEntity mediaEntity) throws IOException {
    if (!(mediaEntity.getResource() instanceof WxMediaResource)) {
        return null;
    }
    WxMediaResource wxMediaResource = (WxMediaResource) mediaEntity.getResource();
    if (wxMediaResource.isUrlMedia()) {
        return null;
    }
    String fileName = wxMediaResource.getFilename();
    if (fileName == null) {
        fileName = mediaEntity.getMediaId();
    }
    File file = new File(StringUtils.applyRelativePath(Type.TEMP.equals(mediaEntity.getStoreType()) ? defaultTempFilePath : defaultFilePath, fileName));
    if (file.exists()) {
        return new FileSystemResource(file);
    }
    file.createNewFile();
    file.setLastModified(System.currentTimeMillis());
    FileCopyUtils.copy(mediaEntity.getResource().getInputStream(), new FileOutputStream(file));
    mediaEntity.setResourcePath(file.getAbsolutePath());
    store(mediaEntity);
    return new FileSystemResource(file);
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:31,代码来源:MapDbWxMediaStore.java

示例2: storeTempMediaToFile

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * 保存tempMedia到File
 *
 * @param mediaId
 * @return File
 */
public File storeTempMediaToFile(String mediaId, Resource resource) throws IOException {
    WxMediaResource wxMediaResource = (WxMediaResource) resource;
    if (wxMediaResource.isUrlMedia()) {
        return null;
    }
    String fileName = resource.getFilename();
    if (fileName == null) {
        fileName = mediaId;
    }
    File file = new File(StringUtils.applyRelativePath(defaultTempFilePath, fileName));
    if (file.exists()) {
        return file;
    }
    StoreEntity storeEntity = storeFile(file, mediaId, resource);
    tempMediaFileDb.put(file.getAbsolutePath(), storeEntity);
    tempMediaIdDb.put(mediaId, file.getAbsolutePath());
    db.commit();
    return file;
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:26,代码来源:WxMediaStore.java

示例3: storeMediaToFile

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * 保存media到File
 *
 * @param mediaId
 * @return File
 */
public File storeMediaToFile(String mediaId, Resource resource) throws IOException {
    String fileName = resource.getFilename();
    if (fileName == null) {
        fileName = mediaId;
    }
    File file = new File(StringUtils.applyRelativePath(defaultFilePath, fileName));
    if (file.exists()) {
        return file;
    }
    StoreEntity storeEntity = storeFile(file, mediaId, resource);
    mediaFileDb.put(file.getAbsolutePath(), storeEntity);
    mediaIdDb.put(mediaId, file.getAbsolutePath());
    db.commit();
    return file;
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:22,代码来源:WxMediaStore.java

示例4: getFile

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public synchronized File getFile(String path) throws IOException {
    if (this.file == null) {
        // 拿到临时文件路径
        String pathToUse = StringUtils.applyRelativePath(path, this.filename);
        this.file = new File(pathToUse);
        if (!this.file.exists()) {
            this.file.getParentFile().mkdirs();
            this.file.createNewFile();
        }
        FileCopyUtils.copy(this.getBody(), file);
    }
    return this.file;
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:14,代码来源:WxMediaResource.java

示例5: createRelative

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public Resource createRelative(String mediaId) throws IOException {
    if (isFileResource) {
        String pathToUse = StringUtils.applyRelativePath(StringUtils.cleanPath(file.getPath()), mediaId);
        return new WxMediaResource(new File(pathToUse));
    }
    return WxContextUtils.getBean(WxApiService.class).getTempMedia(mediaId);
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:9,代码来源:WxMediaResource.java

示例6: createRelative

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * This implementation creates a ServletContextResource, applying the given path
 * relative to the path of the underlying file of this resource descriptor.
 * @see org.springframework.util.StringUtils#applyRelativePath(String, String)
 */
@Override
public Resource createRelative(String relativePath) {
	String pathToUse = StringUtils.applyRelativePath(this.path, relativePath);
	return new ServletContextResource(this.servletContext, pathToUse);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:ServletContextResource.java

示例7: createRelative

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * Returns a resource relative to this resource. This implementation creates
 * an <code>OsgiBundleResource</code>, applying the given path relative to
 * the path of the underlying resource of this descriptor.
 * 
 * @param relativePath the relative path (relative to this resource)
 * @return the resource handle for the relative resource
 * @throws IOException if the relative resource cannot be determined
 * @see org.springframework.util.StringUtils#applyRelativePath(String,
 *      String)
 */
public Resource createRelative(String relativePath) {
	String pathToUse = StringUtils.applyRelativePath(this.path, relativePath);
	return new OsgiBundleResource(this.bundle, pathToUse);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:16,代码来源:OsgiBundleResource.java


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