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


Java FileUtil.normalizePath方法代码示例

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


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

示例1: initializeHome

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Initialize variables holding the user directory.
 */
private void initializeHome() {
    String homeRaw = System.getProperty("user.home");               //NOI18N
    if (homeRaw != null) {
        homePath = FileUtil.normalizePath(homeRaw);
        home = FileUtil.toFileObject(new File(homePath));
    }
    homeInitialized = true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:GlobalVisibilityQueryImpl.java

示例2: normalizeFile

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Normalize a file path to a clean form.
 * <b>This method might block for a longer time and shouldn't be called in EDT.
 * 
 * @return a VCSFileProxy with a normalized file path
 * @see FileUtil#normalizePath(java.lang.String) 
 */
public VCSFileProxy normalizeFile() {
    if (proxy == null) {
        return new VCSFileProxy(FileUtil.normalizePath(path), null);
    } else {
        return proxy.normalize(this);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:VCSFileProxy.java

示例3: findFile

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static @CheckForNull
FileObject findFile(FileObject docFO, String path) {
    if (path == null || path.trim().isEmpty()) {
        return null;
    }
    
    Project prj = FileOwnerQuery.getOwner(docFO);
    if (prj == null) {
        return null;
    }
    
    Sources srcs = ProjectUtils.getSources(prj);
    SourceGroup[] grps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    if (grps.length == 0) {
        return null;
    }

    // XXX other source roots?
    final FileObject rootFolder = grps[0].getRootFolder();
    ClassPath cp = ClassPath.getClassPath(rootFolder, ClassPath.SOURCE);
    if (cp == null) {
        return null;
    }
    
    FileObject fo;
    String rootPath = FileUtil.normalizePath(rootFolder.getPath());
    String docPath = FileUtil.normalizePath(docFO.getParent().getPath());
    if (!docPath.startsWith(rootPath)) {
        // #228262 sanity check, for files which are outside of any source root
        return null;
    }

    // Java Controller
    String javaPath = path.trim().replace("\"", "").replace('.', '/') + ".java"; // NOI18N
    fo = cp.findResource(javaPath);
    if (fo == null) {
        javaPath = docPath.substring(rootPath.length()) + '/' + javaPath; // NOI18N
        fo = cp.findResource(javaPath);
    }
    
    // CSS file
    if (fo == null) {
        // try short path
        String cssPath = path.trim().replace("\"", "").replace("@", ""); // NOI18N
        fo = cp.findResource(cssPath);
        // try full path
        if (fo == null) {
            cssPath = docPath.substring(rootPath.length()) + '/' + cssPath; // NOI18N
            fo = cp.findResource(cssPath);
        }
    }
    return fo;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:54,代码来源:FXMLHyperlinkProvider.java


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