當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。