本文整理汇总了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;
}
示例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);
}
}
示例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;
}