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


Java FileUtil.compactPath方法代码示例

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


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

示例1: resolveResource

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    // systemId should be mandatory
    if (systemId == null) {
        throw new IllegalArgumentException(String.format("Resource: %s refers an invalid resource without SystemId."
                + " Invalid resource has type: %s, namespaceURI: %s, publicId: %s, systemId: %s, baseURI: %s", resourceUri, type, namespaceURI, publicId, systemId, baseURI));
    }
    String resourceURI = null;
    // Build up the relative path for using relatedURI and baseURI
    if (baseURI == null) {
        relatedURI = FileUtil.compactPath(getUri(systemId), '/');
        resourceURI = relatedURI;
    } else {
        String relatedPath = relatedURIMap.get(baseURI);
        if (relatedPath == null) {
            relatedPath = FileUtil.onlyPath(relatedURI);
            if (relatedPath == null) {
                relatedPath = "";
            }
            relatedURI = FileUtil.compactPath(FileUtil.onlyPath(relatedURI) + "/" + systemId, '/');
            resourceURI = relatedURI;
            relatedURIMap.put(baseURI, relatedPath);
        } else {
            resourceURI = FileUtil.compactPath(relatedPath + "/" + systemId, '/');
            relatedURI = resourceURI;
        }
    }
    return new DefaultLSInput(publicId, systemId, baseURI, resourceURI);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:DefaultLSResourceResolver.java

示例2: changeToParentDirectory

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
public synchronized void changeToParentDirectory() throws GenericFileOperationFailedException {
    LOG.trace("changeToParentDirectory()");
    String current = getCurrentDirectory();

    String parent = FileUtil.compactPath(current + "/..");
    // must start with absolute
    if (!parent.startsWith("/")) {
        parent = "/" + parent;
    }

    changeCurrentDirectory(parent);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:SftpOperations.java

示例3: changeCurrentDirectory

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
public synchronized void changeCurrentDirectory(String path) throws GenericFileOperationFailedException {
    LOG.trace("changeCurrentDirectory({})", path);
    if (ObjectHelper.isEmpty(path)) {
        return;
    }

    // must compact path so SFTP server can traverse correctly, make use of the '/'
    // separator because JSch expects this as the file separator even on Windows
    String before = path;
    char separatorChar = '/';
    path = FileUtil.compactPath(path, separatorChar);
    if (LOG.isTraceEnabled()) {
        LOG.trace("Compacted path: {} -> {} using separator: {}", new Object[]{before, path, separatorChar});
    }

    // not stepwise should change directory in one operation
    if (!endpoint.getConfiguration().isStepwise()) {
        doChangeDirectory(path);
        return;
    }
    if (getCurrentDirectory().startsWith(path)) {
        // extract the path segment relative to the target path and make sure it keeps the preceding '/' for the regex op
        String p = getCurrentDirectory().substring(path.length() - (path.endsWith("/") ?  1 : 0));
        if (p.length() == 0) {
            return;
        }
        // the first character must be '/' and hence removed
        path = UP_DIR_PATTERN.matcher(p).replaceAll("/..").substring(1);
    }

    // if it starts with the root path then a little special handling for that
    if (FileUtil.hasLeadingSeparator(path)) {
        // change to root path
        doChangeDirectory(path.substring(0, 1));
        path = path.substring(1);
    }

    // split into multiple dirs
    final String[] dirs = path.split("/|\\\\");

    if (dirs == null || dirs.length == 0) {
        // path was just a relative single path
        doChangeDirectory(path);
        return;
    }

    // there are multiple dirs so do this in chunks
    for (String dir : dirs) {
        doChangeDirectory(dir);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:52,代码来源:SftpOperations.java

示例4: resolveUriPath

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
/**
 * Helper operation used to remove relative path notation from
 * resources.  Most critical for resources on the Classpath
 * as resource loaders will not resolve the relative paths correctly.
 *
 * @param name the name of the resource to load
 * @return the modified or unmodified string if there were no changes
 */
private static String resolveUriPath(String name) {
    // compact the path and use / as separator as that's used for loading resources on the classpath
    return FileUtil.compactPath(name, '/');
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:OsgiClassResolver.java


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