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

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

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

FileUtil.getArchiveFile介绍

[英]Returns the URL of the archive file containing the file referred to by a jar-protocol URL. Remember that any path within the archive is discarded so you may need to check for non-root entries.
[中]返回包含jar协议URL引用的文件的存档文件的URL。请记住,存档中的任何路径都将被丢弃,因此您可能需要检查非根条目。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

String protocol = url.getProtocol();
if ("jar".equals(protocol)) {//NOI18N
  URL tmp = FileUtil.getArchiveFile(url);
  url = (tmp != null) ? tmp : url;
  protocol = url.getProtocol();

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

displayName = f.getAbsolutePath();
} else {
  FileObject archiveFile = FileUtil.getArchiveFile(fo);

代码示例来源:origin: dcaoyuan/nbscala

/**
 * Returns true if the given URL is file based, it is already
 * resolved either into file URL or jar URL with file path.
 * @param URL url
 * @return true if  the URL is normal
 */
private static boolean isNormalizedURL (URL url) {
  if ("jar".equals(url.getProtocol())) { //NOI18N
    url = FileUtil.getArchiveFile(url);
  }
  return "file".equals(url.getProtocol());    //NOI18N
}

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

/**
 * Returns true if the given URL is file based, it is already
 * resolved either into file URL or jar URL with file path.
 * @param URL url
 * @return true if  the URL is normal
 */
private static boolean isNormalizedURL (URL url) {
  if ("jar".equals(url.getProtocol())) { //NOI18N
    url = FileUtil.getArchiveFile(url);
  }
  return "file".equals(url.getProtocol());    //NOI18N
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-project-jsf

/**
 * Returns true if the given URL is file based, it is already
 * resolved either into file URL or jar URL with file path.
 * @param URL url
 * @return true if  the URL is normal
 */
private static boolean isNormalizedURL (URL url) {
  if ("jar".equals(url.getProtocol())) { //NOI18N
    url = FileUtil.getArchiveFile(url);
  }
  return "file".equals(url.getProtocol());    //NOI18N
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-project-jsf

/**
 * Returns true if the given URL is file based, it is already
 * resolved either into file URL or jar URL with file path.
 * @param URL url
 * @return true if  the URL is normal
 */
private static boolean isNormalizedURL (URL url) {
  if ("jar".equals(url.getProtocol())) { //NOI18N
    url = FileUtil.getArchiveFile(url);
  }
  return "file".equals(url.getProtocol());    //NOI18N
}

代码示例来源:origin: dcaoyuan/nbscala

/**
 * Returns true if the given URL is file based, it is already
 * resolved either into file URL or jar URL with file path.
 * @param URL url
 * @return true if  the URL is normal
 */
private static boolean isNormalizedURL (URL url) {
  if ("jar".equals(url.getProtocol())) { //NOI18N
    url = FileUtil.getArchiveFile(url);
  }
  return "file".equals(url.getProtocol());    //NOI18N
}

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

/**
 * Returns true if the given URL is file based, it is already
 * resolved either into file URL or jar URL with file path.
 * @param URL url
 * @return true if  the URL is normal
 */
private static boolean isNormalizedURL (URL url) {
  if ("jar".equals(url.getProtocol())) { //NOI18N
    url = FileUtil.getArchiveFile(url);
  }
  return "file".equals(url.getProtocol());    //NOI18N
}

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

/**
 * Returns true if the given URL is file based, it is already
 * resolved either into file URL or jar URL with file path.
 * @param URL url
 * @return true if  the URL is normal
 */
private static boolean isNormalizedURL (URL url) {
  if ("jar".equals(url.getProtocol())) { //NOI18N
    url = FileUtil.getArchiveFile(url);
  }
  return "file".equals(url.getProtocol());    //NOI18N
}

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

/**
 * Returns true if the given URL is file based, it is already
 * resolved either into file URL or jar URL with file path.
 * @param URL url
 * @return true if  the URL is normal
 */
private static boolean isNormalizedURL (URL url) {
  if ("jar".equals(url.getProtocol())) { //NOI18N
    url = FileUtil.getArchiveFile(url);
  }
  return "file".equals(url.getProtocol());    //NOI18N
}

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

public static File getRootFile (final URL url) {
  File rootFile;
  if ("jar".equals(url.getProtocol())) {  //NOI18N
    rootFile = new File (URI.create(FileUtil.getArchiveFile(url).toExternalForm()));
  }
  else {
    rootFile = new File (URI.create(url.toExternalForm()));
  }
  return rootFile;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-rakeproject

/** Find the time the file this URL represents was last modified xor its size, if possible. */
private static long checkFootprint(URL u) {
  URL nested = FileUtil.getArchiveFile(u);
  if (nested != null) {
    u = nested;
  }
  if (u.getProtocol().equals("file")) { // NOI18N
    File f = new File(URI.create(u.toExternalForm()));
    return f.lastModified() ^ f.length();
  } else {
    return 0L;
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

private static long getTimeStamp(final FileObject root) {
    final FileObject archiveFile = FileUtil.getArchiveFile(root);
    return archiveFile != null ? root.lastModified().getTime() : -1L;
  }
}

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

public static boolean isRefactorable(FileObject fo) {
  if (fo != null && (FileUtil.getArchiveFile(fo) != null || !fo.canWrite())) {
    return false;
  }
  return true;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mobility-cldcplatform

public static String getFilePath(final FileObject fo) {
  if (fo == null)
    return null;
  FileObject ff = FileUtil.getArchiveFile(fo);
  if (ff == null)
    ff = fo;
  final File file = FileUtil.toFile(ff);
  return (file != null) ? file.getAbsolutePath() : null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans

private static ClassPath createClassPath(List<URL> roots) {
    List<URL> jarRootURLs = new ArrayList<URL>();
    for (URL url : roots) {
      // Workaround for #126307: ClassPath roots should be JAR root URL, not file URLs.
      if (FileUtil.getArchiveFile(url) == null) {
        // Not an archive root URL.
        url = FileUtil.getArchiveRoot(url);
      }
      jarRootURLs.add(url);
    }
    return ClassPathSupport.createClassPath((jarRootURLs.toArray(new URL[jarRootURLs.size()])));
  }
}

代码示例来源:origin: hmvictor/radar-netbeans

private static String getLibrariesPath(ClassPath classPath) {
  StringBuilder librariesPath = new StringBuilder();
  for (FileObject root : classPath.getRoots()) {
    if (librariesPath.length() > 0) {
      librariesPath.append(',');
    }
    FileObject archiveFile = FileUtil.getArchiveFile(root);
    if (archiveFile != null) {
      librariesPath.append(archiveFile.getPath());
    }
  }
  return librariesPath.toString();
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2me-cdc-platform

void setSources (ClassPath sources) {
  String srcPath = null;
  if (sources.entries().size()>0) {
    URL folderRoot = ((ClassPath.Entry)sources.entries().get(0)).getURL();
    if ("jar".equals(folderRoot.getProtocol())) {   //NOI18N
      folderRoot = FileUtil.getArchiveFile (folderRoot);
    }
    srcPath = new File(URI.create(folderRoot.toExternalForm())).getAbsolutePath();
  }
  setSources (srcPath);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-clientproject

@Override
public File[] getRequiredLibraries() {
  ClassPath cp = ClassPathFactory.createClassPath(
        ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
        FileUtil.toFile(project.getProjectDirectory()), project.evaluator(), new String[]{"javac.classpath"}));
  List<File> files = new ArrayList<File>();
  for (FileObject fo : cp.getRoots()) {
    fo = FileUtil.getArchiveFile(fo);
    if (fo == null) {
      continue;
    }
    files.add(FileUtil.toFile(fo));
  }
  return files.toArray(new File[files.size()]);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-ejbjarproject

@Override
public File[] getRequiredLibraries() {
  ClassPath cp = ClassPathFactory.createClassPath(
        ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
        FileUtil.toFile(project.getProjectDirectory()), project.evaluator(), new String[]{"javac.classpath"}));
  List<File> files = new ArrayList<File>();
  for (FileObject fo : cp.getRoots()) {
    fo = FileUtil.getArchiveFile(fo);
    if (fo == null) {
      continue;
    }
    files.add(FileUtil.toFile(fo));
  }
  return files.toArray(new File[files.size()]);
}

相关文章