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

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

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

FileUtil.toFile介绍

[英]Finds appropriate java.io.File to FileObject if possible. If not possible then null is returned. This is the inverse operation of #toFileObject.
[中]找到合适的java。木卫一。如果可能,将文件转换为FileObject。如果不可能,则返回null。这是#toFileObject的逆运算。

代码示例

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

/**
 * Tests if this file can be read.
 * <P>
 * The default implementation simply uses <code> java.io.File.canRead </code>
 * if there exists conversion to <code> java.io.File</code> (see {@link FileUtil#toFile}).
 * If conversion is not possible, then <code>true </code> is returned.
 * @return true if this file can be read, false if not.
 * @since 3.31
 */
public boolean canRead() {
  File f = FileUtil.toFile(this);
  if (f != null) {
    return f.canRead();
  }
  return true;
}

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

/**
 * Tests if this file can be written to.
 * <P>
 * The default implementation simply uses <code> java.io.File.canWrite </code>
 * if there exists conversion to <code> java.io.File</code> (see {@link FileUtil#toFile}).
 * If conversion is not possible, then deprecated method {@link #isReadOnly} is used.
 * @return true if this file can be written, false if not.
 * @since 3.31
 */
public boolean canWrite() {
  File f = FileUtil.toFile(this);
  if (f != null) {
    return f.canWrite();
  }
  return !isReadOnly();
}

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

private static String getArchiveDisplayName(FileObject fo, FileObject archiveFile) {
  String displayName = null;
  File f = FileUtil.toFile(archiveFile);
  if (f != null) {
    String archivDisplayName = f.getAbsolutePath();
    if (fo.isRoot()) {
      displayName = archivDisplayName;
    } else {
      String entryPath = fo.getPath();
      displayName = NbBundle.getMessage(
          FileUtil.class, "LBL_file_in_filesystem", entryPath, archivDisplayName
        );
    }
  }
  return displayName;
}

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

@Override
public void fileRenamed(FileRenameEvent fe) {
  File f = FileUtil.toFile(fe.getFile());
  if ((f != null) && !f.equals(aRoot)) {
    try {
      setJarFile(f, false, true);
    } catch (IOException iex) {
      ExternalUtil.exception(iex);
    } catch (PropertyVetoException pvex) {
      ExternalUtil.exception(pvex);
    }
  }
}

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

XMLUtil.write(document, os, "UTF-8"); //NOI18N
} catch (IOException e) {
  ERR.log(Level.SEVERE, "Cannot write resolver " + (newUserDefinedFO == null ? "" : FileUtil.toFile(newUserDefinedFO)), e);  //NOI18N
} finally {
  if (os != null) {
      os.close();
    } catch (IOException e) {
      ERR.log(Level.SEVERE, "Cannot close OutputStream of file " + (newUserDefinedFO == null ? "" : FileUtil.toFile(newUserDefinedFO)), e);  //NOI18N

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

public Permission getPermission() throws IOException {
  // Note this is normally called by URLClassPath with an unconnected
  // URLConnection, so the fo will probably be null anyway.
  if (fo != null) {
    File f = FileUtil.toFile(fo);
    if (f != null) {
      return new FilePermission(f.getAbsolutePath(), "read"); // NOI18N
    }
    try {
      FileSystem fs = fo.getFileSystem();
      if (fs instanceof JarFileSystem) {
        return new FilePermission(((JarFileSystem) fs).getJarFile().getAbsolutePath(), "read"); // NOI18N
      }
      // [PENDING] could do XMLFileSystem too...
    } catch (FileStateInvalidException fsie) {
      // ignore
    }
  }
  // fallback
  return new FilePermission("<<ALL FILES>>", "read"); // NOI18N
}

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

ERR.log(Level.SEVERE, "Cannot delete resolver " + FileUtil.toFile(userDefinedResolverFO), e);  //NOI18N
return false;

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

File f = FileUtil.toFile(fo);

代码示例来源:origin: org.codehaus.mevenide/nb-project

OtherGroup(NbMavenProject p, FileObject rootFold, String nm, String displayNm/*,
        Icon icn, Icon opened*/) {
      project = p;
      rootFolder = rootFold;
      rootFile = FileUtil.toFile(rootFolder);
      name = nm;
      displayName = displayNm != null ? displayNm : NbBundle.getMessage(MavenSourcesImpl.class, "SG_Root_not_defined");
//            icon = icn;
//            openedIcon = opened;
    }

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

private static int getDepth(final FileObject fo) {
  String path = FileUtil.toFile(fo).getAbsolutePath();
  StringTokenizer toker = new StringTokenizer(path, File.separator);
  return toker.countTokens();
}

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

/** Take one file object and try to convert it into a local file.
* @param fo file object to convert
* @return disk file for that file object, or <code>null</code> if there is no corresponding disk file
* @deprecated You should use {@link org.openide.filesystems.FileUtil#toFile} instead.
*/
public static File toFile (FileObject fo) {
  Thread.dumpStack();
  return FileUtil.toFile(fo);
}

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

public void store () throws IOException {
  final File indexDir = FileUtil.toFile(context.getIndexFolder());
  final File f = new File (indexDir, CHECK_SUMS_FILE);
  try(final OutputStream out = new FileOutputStream(f)) {
    props.store(out, ""); //NOI18N
  }
}

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

private void load() throws IOException {
  final File indexDir = FileUtil.toFile(context.getIndexFolder());
  final File f = new File (indexDir, CHECK_SUMS_FILE);
  if (f.canRead()) {
    try (final InputStream in = new FileInputStream(f)) {
      props.load(in);
    } catch (IllegalArgumentException iae) {
      props.clear();
    }
  }
}

代码示例来源:origin: org.codehaus.mevenide/nb-project

private Listener(Project prj) {
  File fl = FileUtil.toFile(prj.getProjectDirectory());
  root = new File(fl, "target" + File.separator + "site"); //NOI18N
}
public void outputLineSelected(OutputEvent arg0) {

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

public static File toFile(FileObject fileObject) {
  // TODO: do we still need this?
  File file = FileUtil.toFile(fileObject);
  if (file == null && fileObject != null && !fileObject.isValid()) {
    file = new File(fileObject.getPath());
  }
  return file;
}

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

public static File getFile(Document bDoc) {
  DataObject dobj = NbEditorUtilities.getDataObject(bDoc);
  if (dobj != null && dobj.isValid()) {
    FileObject fo = dobj.getPrimaryFile();
    if (fo != null) {
      File file = FileUtil.toFile(fo);
      return file;
    }
  }
  return null;
}

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

public ClassPathProviderImpl(AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots sourceRoots,
    SourceRoots testSourceRoots) {
  this.helper = helper;
  this.projectDirectory = FileUtil.toFile(helper.getProjectDirectory());
  assert this.projectDirectory != null;
  this.evaluator = evaluator;
  this.sourceRoots = sourceRoots;
  this.testSourceRoots = testSourceRoots;
  this.bootClassPathImpl = new BootClassPathImplementation(evaluator);
  evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, evaluator));
}

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

private void btnDefinitionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDefinitionActionPerformed
    File f = FileUtil.toFile(helper.getProjectDirectory()); // NOI18N
    String curr = SharableLibrariesUtils.browseForLibraryLocation(getLibraryLocation(), this, f);
    if (curr != null) {
      setLibraryLocation(curr);
    }

}//GEN-LAST:event_btnDefinitionActionPerformed

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

public synchronized ClassPath getJ2eePlatformClassPath() {
  if (platformClassPath == null) {
    platformClassPath = ClassPathFactory.createClassPath(ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
        FileUtil.toFile(project.getProjectDirectory()), project.evaluator(), new String[] {WebProjectProperties.J2EE_PLATFORM_CLASSPATH }));
  }
  return platformClassPath;
}

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

@Override
  @CheckForNull
  protected URL map(@NonNull final FileObject fo) {
    final String relative = FileObjects.convertFolder2Package(
        FileObjects.stripExtension(FileObjects.getRelativePath(cacheRoot, FileUtil.toFile(fo))), File.separatorChar);
    final FileObject sourceFile = SourceUtils.getFile(
      ElementHandleAccessor.getInstance().create(ElementKind.CLASS, relative),
      resolveCps);
    return sourceFile == null ? null : sourceFile.toURL();
  }            
}

相关文章