org.openide.filesystems.FileUtil.normalizePath()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.openide.filesystems.FileUtil.normalizePath()方法的一些代码示例,展示了FileUtil.normalizePath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.normalizePath()方法的具体详情如下:
包路径:org.openide.filesystems.FileUtil
类名称:FileUtil
方法名:normalizePath

FileUtil.normalizePath介绍

[英]See #normalizeFile for details
[中]有关详细信息,请参见#规范化文件

代码示例

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-api-remote

public static String normalizeAbsolutePath(String absPath, ExecutionEnvironment execEnv) {
  if (execEnv.isRemote()) {
    return FileSystemProvider.normalizeAbsolutePath(absPath, execEnv);
  } else {
    return FileUtil.normalizePath(absPath);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

@Override
public FileObject toFileObjectImpl(CharSequence absPath) {
  FileObject  fo;
  for (CndFileSystemProvider provider : cache) {
    fo = provider.toFileObjectImpl(absPath);
    if (fo != null) {
      return fo;
    }
  }
  // not cnd specific file => use default file system conversion
  File file = new File(FileUtil.normalizePath(absPath.toString()));
  fo = FileUtil.toFileObject(file);
  if (fo == null) {
    fo = InvalidFileObjectSupport.getInvalidFileObject(file);
  }
  return fo;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

@Override
protected FileObject urlToFileObjectImpl(CharSequence url) {
  for (CndFileSystemProvider provider : cache) {
    FileObject fo = provider.urlToFileObjectImpl(url);
    if (fo != null) {
      return fo;
    }
  }
  String path = url.toString();
  File file;
  if (path.startsWith(FILE_PROTOCOL_PREFIX)) {
    try {
      URL u = new URL(path);
      file = FileUtil.normalizeFile(new File(u.toURI()));
    } catch (IllegalArgumentException ex) {
      CndUtils.getLogger().log(Level.WARNING, "CndFileSystemProvider.urlToFileObjectImpl can not convert {0}:\n{1}", new Object[]{path, ex.getLocalizedMessage()});
      return null;
    } catch (URISyntaxException ex) {
      CndUtils.getLogger().log(Level.WARNING, "CndFileSystemProvider.urlToFileObjectImpl can not convert {0}:\n{1}", new Object[]{path, ex.getLocalizedMessage()});
      return null;
    } catch (MalformedURLException ex) {
      CndUtils.getLogger().log(Level.WARNING, "CndFileSystemProvider.urlToFileObjectImpl can not convert {0}:\n{1}", new Object[]{path, ex.getLocalizedMessage()});
      return null;
    }       
  } else {
    file = new File(FileUtil.normalizePath(path));
  }
  return FileUtil.toFileObject(file);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

private static Flags get(FileSystem fs, String absPath) {
  FileObject fo;
  if (isLocalFileSystem(fs)) {
    absPath = FileUtil.normalizePath(absPath);
    fo = CndFileSystemProvider.toFileObject(absPath);                
  } else {
    fo = fs.findResource(absPath);
  }
  return get(fo);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-apt

new Object[]{
  fileSystem, path, 
  FileUtil.toFileObject(new File(FileUtil.normalizePath(path.toString()))), 
  fileSystem.findResource(path.toString())});

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

file = new File(FileUtil.normalizePath(path));

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui

return ;
String d = FileUtil.normalizePath(zipOrDir.getAbsolutePath());
synchronized (SourcesCurrentModel.this) {
  additionalSourceRoots.add(d);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui

return ;
String d = FileUtil.normalizePath(zipOrDir.getAbsolutePath());
synchronized (SourcesRemoteModel.this) {
  additionalSourceRoots.add(d);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-junit-ant

private Project getProjectFromAttributes(AntEvent event, TaskStructure taskStructure) {
  if (taskStructure.getName().equals("test")) { //NOI18N
    String attribute = taskStructure.getAttribute("name"); //NOI18N
    if (attribute != null) {
      String name = event.evaluate(attribute);
      String fileName = name.replace(".", "/").concat(".java"); //NOI18N
      FileObject fo = GlobalPathRegistry.getDefault().findResource(fileName);
      if (fo != null) {
        return FileOwnerQuery.getOwner(fo);
      }
    }
  }
  if (taskStructure.getName().equals("fileset")) { //NOI18N
    String attribute = taskStructure.getAttribute("dir"); //NOI18N
    if (attribute == null) {
      attribute = taskStructure.getAttribute("file"); //NOI18N
    }
    if (attribute != null) {
      String dir = event.evaluate(attribute);
      FileObject fo = FileUtil.toFileObject(new File(FileUtil.normalizePath(dir)));
      if (fo != null) {
        return FileOwnerQuery.getOwner(fo);
      }
    }
  }
  return null;
}

相关文章

微信公众号

最新文章

更多