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

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

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

FileUtil.archiveOrDirForURL介绍

[英]Convert a classpath-type URL to a corresponding file. If it is a jar URL representing the root folder of a local disk archive, that archive file will be returned. If it is a file URL representing a local disk folder, that folder will be returned.
[中]将类路径类型URL转换为相应的文件。如果它是表示本地磁盘存档的根文件夹的jarURL,则将返回该存档文件。如果是表示本地磁盘文件夹的fileURL,则将返回该文件夹。

代码示例

代码示例来源:origin: AlexFalappa/nb-springboot

private void updateResourceFolder(boolean isTest) {
  final URI[] resources = nbProj.getResources(isTest);
  if (resources.length > 0) {
    try {
      resourceFolder = FileUtil.archiveOrDirForURL(resources[0].toURL());
    } catch (MalformedURLException ex) {
      Exceptions.printStackTrace(ex);
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-hints-declarative-test

private static Collection<String> listTests(Class<?> clazz) {
  File dirOrArchive = FileUtil.archiveOrDirForURL(clazz.getProtectionDomain().getCodeSource().getLocation());
  assertTrue(dirOrArchive.exists());
  if (dirOrArchive.isFile()) {
    return listTestsFromJar(dirOrArchive);
  } else {
    Collection<String> result = new LinkedList<String>();
    listTestsFromFilesystem(dirOrArchive, "", result);
    return result;
  }
}

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

@NonNull
private static StringBuilder append (
    @NonNull final StringBuilder builder,
    @NonNull final URL url) {
  final File f = FileUtil.archiveOrDirForURL(url);
  if (f != null) {
    if (builder.length() > 0) {
      builder.append(File.pathSeparatorChar);
    }
    builder.append(f.getAbsolutePath());
  } else {
    if (builder.length() > 0) {
      builder.append(File.pathSeparatorChar);
    }
    builder.append(url);
  }
  return builder;
}

代码示例来源:origin: AlexFalappa/nb-springboot

@Override
public void readSettings(WizardDescriptor wiz) {
  try {
    final Project project = Templates.getProject(wiz);
    NbMavenProject nbProj = project.getLookup().lookup(NbMavenProject.class);
    final URI[] resources = nbProj.getResources(false);
    File resourceFolder = FileUtil.normalizeFile(FileUtil.archiveOrDirForURL(resources[0].toURL()));
    File addMeta = new File(resourceFolder, "META-INF/additional-spring-configuration-metadata.json");
    if (addMeta.exists()) {
      wiz.putProperty(WizardDescriptor.PROP_WARNING_MESSAGE, "Existing additional metadata file will be overwritten!");
    }
  } catch (Exception ex) {
    Exceptions.printStackTrace(Exceptions.attachSeverity(ex, Level.WARNING));
  }
  getComponent().read(wiz);
}

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

@Override
public void accept(@NonNull final URL url) {
  synchronized (this) {
    load();
    if (used == null || used == TOMBSTONE) {
      used = new LongHashMap<>();
    }
    final File f = FileUtil.archiveOrDirForURL(url);
    if (f != null) {
      final long size = f.isFile() ?
          f.length() :
          -1;
      if (!used.containsKey(f)) {
        used.put(f, size);
        saveTask.schedule(DEFERRED_SAVE);
      }
    }
  }
}

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

.collect(Collectors.toSet());
final Set<File> currentAllFiles = pp.entries().stream()
    .map((e) -> FileUtil.archiveOrDirForURL(e.getURL()))
    .filter((file) -> file != null)
    .collect(Collectors.toSet());

代码示例来源:origin: AlexFalappa/nb-springboot

Path resourceFolder = FileUtil.archiveOrDirForURL(resources[0].toURL()).toPath();
File fDir = resourceFolder.resolve("META-INF").toFile();

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

List<URL> projectDeps = new ArrayList<URL>();
for (ClassPath.Entry entry : compileCP.entries()) {
  File archiveOrDir = FileUtil.archiveOrDirForURL(entry.getURL());
  if (archiveOrDir == null || !platformClasspath.contains(archiveOrDir)) {
    projectDeps.add(entry.getURL());

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

List<URL> projectDeps = new ArrayList<URL>();
for (ClassPath.Entry entry : compileCP.entries()) {
  File archiveOrDir = FileUtil.archiveOrDirForURL(entry.getURL());
  if (archiveOrDir == null || !platformClasspath.contains(archiveOrDir)) {
    projectDeps.add(entry.getURL());

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

protected void configureSourcesAndBinariesProperties(Version sonarQubeVersion, Properties properties) {
  SourceGroup mainSourceGroup = getMainSourceGroup();
  if (mainSourceGroup != null) {
    String sourcePath = mainSourceGroup.getRootFolder().getPath();
    if (SonarMvnProject.isMvnProject(projectContext.getProject()) && sonarQubeVersion.compareTo(4, 5) >= 0) {
      sourcePath = "pom.xml," + sourcePath;
    }
    ClassPath classPath = ClassPath.getClassPath(projectContext.getProject().getProjectDirectory(), ClassPath.COMPILE);
    if (classPath != null) {
      properties.setProperty(getPropertyName("sonar.java.libraries"), getLibrariesPath(classPath));
    }
    properties.setProperty(getPropertyName("sonar.sources"), sourcePath);
    URL[] roots = BinaryForSourceQuery.findBinaryRoots(mainSourceGroup.getRootFolder().toURL()).getRoots();
    if (roots.length > 0) {
      properties.setProperty(getPropertyName("sonar.java.binaries"), Utilities.toFile(roots[0]).getPath());
    }
    URL[] testSources = UnitTestForSourceQuery.findUnitTests(mainSourceGroup.getRootFolder());
    if (testSources != null && testSources.length != 0) {
      File testsDir = FileUtil.archiveOrDirForURL(testSources[0]);
      if (testsDir.exists()) {
        properties.setProperty(getPropertyName("sonar.tests"), testsDir.getPath());
      }
    }
  }
}

相关文章