/** * 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; }
/** * 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(); }
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; }
@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); } } }
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
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 }
ERR.log(Level.SEVERE, "Cannot delete resolver " + FileUtil.toFile(userDefinedResolverFO), e); //NOI18N return false;
File f = FileUtil.toFile(fo);
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; }
private static int getDepth(final FileObject fo) { String path = FileUtil.toFile(fo).getAbsolutePath(); StringTokenizer toker = new StringTokenizer(path, File.separator); return toker.countTokens(); }
/** 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); }
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 } }
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(); } } }
private Listener(Project prj) { File fl = FileUtil.toFile(prj.getProjectDirectory()); root = new File(fl, "target" + File.separator + "site"); //NOI18N } public void outputLineSelected(OutputEvent arg0) {
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; }
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; }
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)); }
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
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; }
@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(); } }