Class FileObject

java.lang.Object
org.openide.filesystems.FileObject
All Implemented Interfaces:
Serializable, org.openide.util.Lookup.Provider

public abstract class FileObject extends Object implements Serializable, org.openide.util.Lookup.Provider
This is the base for all implementations of file objects on a filesystem. Provides basic information about the object (its name, parent, whether it exists, etc.) and operations on it (move, delete, etc.).
See Also:
  • Field Details

    • DEFAULT_LINE_SEPARATOR_ATTR

      public static final String DEFAULT_LINE_SEPARATOR_ATTR
      Name of default line separator attribute. File object can provide default line separator if it differs from System.getProperty("line.separator"). Call fo.getAttribute(DEFAULT_LINE_SEPARATOR_PROP) returns string with default line separator. Default line separator will be used by the text editor if saving new content to an initially empty file. Any other code which creates file content programmatically must manually read this property if it cares.
      Since:
      7.56
      See Also:
    • DEFAULT_PATHNAME_SEPARATOR_ATTR

      public static final String DEFAULT_PATHNAME_SEPARATOR_ATTR
      Name of default path name separator attribute. File object can provide default separator if it differs from File.separator. Call fo.getAttribute(DEFAULT_PATHNAME_SEPARATOR_ATTR) returns string with default separator.
      Since:
      9.6
      See Also:
  • Constructor Details

    • FileObject

      public FileObject()
  • Method Details

    • getName

      public abstract String getName()
      Get the name without extension of this file or folder. Period at first position is not considered as extension-separator For the root folder of a filesystem, this will be the empty string (the extension will also be the empty string, and the fully qualified name with any delimiters will also be the empty string).
      Returns:
      name of the file or folder(in its enclosing folder)
    • getExt

      public abstract String getExt()
      Get the extension of this file or folder. Period at first position is not considered as extension-separator This is the string after the last dot of the full name, if any.
      Returns:
      extension of the file or folder (if any) or empty string if there is none
    • rename

      public abstract void rename(FileLock lock, String name, String ext) throws IOException
      Renames this file (or folder). Both the new basename and new extension should be specified.

      Note that using this call, it is currently only possible to rename within a parent folder, and not to do moves across folders. Conversely, implementing filesystems need only implement "simple" renames. If you wish to move a file across folders, you should call FileUtil.moveFile(org.openide.filesystems.FileObject, org.openide.filesystems.FileObject, java.lang.String).

      Parameters:
      lock - File must be locked before renaming.
      name - new basename of file
      ext - new extension of file (ignored for folders)
      Throws:
      IOException
    • copy

      public FileObject copy(FileObject target, String name, String ext) throws IOException
      Copies this file. This allows the filesystem to perform any additional operation associated with the copy. But the default implementation is simple copy of the file and its attributes Since version 9.32, the file POSIX permissions are copied as well.
      Parameters:
      target - target folder to move this file to
      name - new basename of file
      ext - new extension of file (ignored for folders)
      Returns:
      the newly created file object representing the moved file
      Throws:
      IOException
    • move

      public FileObject move(FileLock lock, FileObject target, String name, String ext) throws IOException
      Moves this file. This allows the filesystem to perform any additional operation associated with the move. But the default implementation is encapsulated as copy and delete.
      Parameters:
      lock - File must be locked before renaming.
      target - target folder to move this file to
      name - new basename of file
      ext - new extension of file (ignored for folders)
      Returns:
      the newly created file object representing the moved file
      Throws:
      IOException
    • toString

      public String toString()
      Gets a textual representation of this FileObject. The precise format is not defined. In particular it is probably not a resource path. For that purpose use getPath() directly.

      Typically it is useful for debugging purposes. Example of correct usage:

       FileObject fo = getSomeFileObject();
       ErrorManager.getDefault().log("Got a change from " + fo);
       
      Overrides:
      toString in class Object
      Returns:
      some representation of this file object
    • getPath

      public String getPath()
      Get the full resource path of this file object starting from the filesystem root. Folders are separated with forward slashes. File extensions, if present, are included. The root folder's path is the empty string. The path of a folder never ends with a slash.

      Subclasses are strongly encouraged to override this method.

      Never use this to get a display name for the file! Use FileUtil.getFileDisplayName(org.openide.filesystems.FileObject).

      Do not use this method to find a file path on disk! Use FileUtil.toFile(org.openide.filesystems.FileObject).

      Returns:
      the path, for example path/from/root.ext
      Since:
      3.7
      See Also:
    • getPackageNameExt

      @Deprecated public String getPackageNameExt(char separatorChar, char extSepChar)
      Deprecated.
      Please use the ClassPath API instead.
      Get fully-qualified filename. Does so by walking through all folders to the root of the filesystem. Separates files with provided separatorChar. The extension, if present, is separated from the basename with extSepChar.

      Note: fo.getPath() will have the same effect as using this method with / and . (the standard path and extension delimiters).

      Parameters:
      separatorChar - char to separate folders and files
      extSepChar - char to separate extension
      Returns:
      the fully-qualified filename
    • getPackageName

      @Deprecated public String getPackageName(char separatorChar)
      Deprecated.
      Please use the ClassPath API instead.
      Get fully-qualified filename, but without extension. Like getPackageNameExt(char, char) but omits the extension.
      Parameters:
      separatorChar - char to separate folders and files
      Returns:
      the fully-qualified filename
    • getNameExt

      public String getNameExt()
      Getter for name and extension of a file object. Dot is used as separator between name and ext.
      Returns:
      string name of the file in the folder (with extension)
    • getFileSystem

      public abstract FileSystem getFileSystem() throws FileStateInvalidException
      Get the filesystem containing this file.

      Note that it may be possible for a stale file object to exist which refers to a now-defunct filesystem. If this is the case, this method will throw an exception.

      Returns:
      the filesystem
      Throws:
      FileStateInvalidException - if the reference to the file system has been lost (e.g., if the filesystem was deleted)
    • getParent

      public abstract FileObject getParent()
      Get parent folder. The returned object will satisfy isFolder().
      Returns:
      the parent folder or null if this object isRoot().
    • isFolder

      public abstract boolean isFolder()
      Test whether this object is a folder.
      Returns:
      true if the file object is a folder (i.e., can have children)
    • lastModified

      public abstract Date lastModified()
      Get last modification time.
      Returns:
      the date
    • isRoot

      public abstract boolean isRoot()
      Test whether this object is the root folder. The root should always be a folder.
      Returns:
      true if the object is the root of a filesystem
    • isData

      public abstract boolean isData()
      Test whether this object is a data object. This is exclusive with isFolder().
      Returns:
      true if the file object represents data (i.e., can be read and written)
    • isValid

      public abstract boolean isValid()
      Test whether the file is valid. The file can be invalid if it has been deserialized and the file no longer exists on disk; or if the file has been deleted.
      Returns:
      true if the file object is valid
    • existsExt

      public boolean existsExt(String ext)
      Test whether there is a file with the same basename and only a changed extension in the same folder. The default implementation asks this file's parent using getFileObject(String name, String ext).
      Parameters:
      ext - the alternate extension
      Returns:
      true if there is such a file
    • delete

      public abstract void delete(FileLock lock) throws IOException
      Delete this file. If the file is a folder and it is not empty then all of its contents are also recursively deleted.
      Parameters:
      lock - the lock obtained by a call to lock()
      Throws:
      IOException - if the file could not be deleted
    • delete

      public final void delete() throws IOException
      Delete this file. If the file is a folder and it is not empty then all of its contents are also recursively deleted. FileObject is locked before delete and finally is this lock released.
      Throws:
      IOException - if the file could not be deleted or FileAlreadyLockedException if the file is already locked lock()
      Since:
      1.15
    • getLookup

      public org.openide.util.Lookup getLookup()
      A lookup containing various logical views of the underlying represented file. The lookup is supposed to contain this FileObject (however not necessarily only one, possibly more). The identity of the lookup should survive move operation - the resulting FileObject after successful move will share the same Lookup as the original FileObject. That is why one can put fileObject.getLookup() into IdentityHashMap<Lookup,Anything> and cache Anything regardless the actual location of (moved) file. Or one can obtain a Lookup.Result from the Lookup, keep its reference, attach a listener to it and be assured that it will fire events even if the file gets renamed.

      Inside of NetBeans Platform application the content of this lookup is usually identical to the one provided by the DataObject.find(this).getLookup(). This functionality is provided by the org.netbeans.modules.settings module. DataObject.move operation preserves the object's identity, and to mimic the same behavior without reference to DataObject the behavior of FileObject.getLookup() has been modelled.

      Specified by:
      getLookup in interface org.openide.util.Lookup.Provider
      Returns:
      lookup providing logical interfaces additionally describing the content of the underlying file
      Since:
      8.0
    • getAttribute

      public abstract Object getAttribute(String attrName)
      Get the file attribute with the specified name.
      Parameters:
      attrName - name of the attribute
      Returns:
      appropriate (serializable) value or null if the attribute is unset (or could not be properly restored for some reason)
    • setAttribute

      public abstract void setAttribute(String attrName, Object value) throws IOException
      Set the file attribute with the specified name. The actual meaning of this method is implementation dependent. It is generally expected that the attribute will later be available from getAttribute(java.lang.String) method.
      Many FileSystem implementations (since version 7.43) support special form of arguments for their setAttribute method. One can use prefix methodvalue: or newvalue: to store references to Method or Class respectively. The meaning is then similar to XMLFileSystem attributes methodvalue and newvalue.
      Parameters:
      attrName - name of the attribute
      value - new value or null to clear the attribute. Must be serializable, although particular filesystems may or may not use serialization to store attribute values.
      Throws:
      IOException - if the attribute cannot be set. If serialization is used to store it, this may in fact be a subclass such as NotSerializableException.
    • getAttributes

      public abstract Enumeration<String> getAttributes()
      Get all file attribute names for this file.
      Returns:
      enumeration of keys (as strings)
    • hasExt

      public final boolean hasExt(String ext)
      Test whether this file has the specified extension.
      Parameters:
      ext - the extension the file should have
      Returns:
      true if the text after the last period (.) is equal to the given extension
    • addFileChangeListener

      public abstract void addFileChangeListener(FileChangeListener fcl)
      Add new listener to this object.
      Parameters:
      fcl - the listener
    • removeFileChangeListener

      public abstract void removeFileChangeListener(FileChangeListener fcl)
      Remove listener from this object.
      Parameters:
      fcl - the listener
    • addRecursiveListener

      public void addRecursiveListener(FileChangeListener fcl)
      Adds a listener to this FileObject and all its children and children or its children. It is guaranteed that whenever a change is made via the FileSystem API itself under this FileObject that it is notified to the fcl listener. Whether external changes (if they make sense) are detected and notified depends on actual implementation. As some implementations may need to perform non-trivial amount of work during initialization of listeners, this methods can take long time. Usage of this method may consume a lot of system resources and as such it shall be used with care. Traditional addFileChangeListener(org.openide.filesystems.FileChangeListener) is definitely preferred variant.

      If you are running with the MasterFS module enabled, it guarantees that for files backed with real File, the system initializes itself to detect external changes on the whole subtree. This requires non-trivial amount of work and especially on slow disks (aka networks ones) may take a long time to add the listener and also refresh the system when refresh() and especially FileUtil.refreshAll() is requested.

      Parameters:
      fcl - the listener to register
      Since:
      7.28
    • removeRecursiveListener

      public void removeRecursiveListener(FileChangeListener fcl)
      Parameters:
      fcl - the listener to remove
      Since:
      7.28
    • fireFileDataCreatedEvent

      protected void fireFileDataCreatedEvent(Enumeration<FileChangeListener> en, FileEvent fe)
      Fire data creation event.
      Parameters:
      en - listeners that should receive the event
      fe - the event to fire in this object
    • fireFileFolderCreatedEvent

      protected void fireFileFolderCreatedEvent(Enumeration<FileChangeListener> en, FileEvent fe)
      Fire folder creation event.
      Parameters:
      en - listeners that should receive the event
      fe - the event to fire in this object
    • fireFileChangedEvent

      protected void fireFileChangedEvent(Enumeration<FileChangeListener> en, FileEvent fe)
      Fire file change event.
      Parameters:
      en - listeners that should receive the event
      fe - the event to fire in this object
    • fireFileDeletedEvent

      protected void fireFileDeletedEvent(Enumeration<FileChangeListener> en, FileEvent fe)
      Fire file deletion event.
      Parameters:
      en - listeners that should receive the event
      fe - the event to fire in this object
    • fireFileAttributeChangedEvent

      protected void fireFileAttributeChangedEvent(Enumeration<FileChangeListener> en, FileAttributeEvent fe)
      Fire file attribute change event.
      Parameters:
      en - listeners that should receive the event
      fe - the event to fire in this object
    • fireFileRenamedEvent

      protected void fireFileRenamedEvent(Enumeration<FileChangeListener> en, FileRenameEvent fe)
      Fire file rename event.
      Parameters:
      en - listeners that should receive the event
      fe - the event to fire in this object
    • getMIMEType

      public String getMIMEType()
      Get the MIME type of this file. The MIME type identifies the type of the file's contents and should be used in the same way as in the Java Activation Framework or in the java.awt.datatransfer package.

      The default implementation calls FileUtil.getMIMEType(java.lang.String). (As a fallback return value, content/unknown is used.)

      Returns:
      the MIME type textual representation, e.g. "text/plain"; never null
    • getMIMEType

      public String getMIMEType(String... withinMIMETypes)
      Resolves MIME type from the list of acceptable ones. By default calls FileUtil.getMIMEType(org.openide.filesystems.FileObject, java.lang.String[]), but subclasses may override this method to be more effective.
      Parameters:
      withinMIMETypes - A hint to the underlaying infrastructure to limit the search to given array of MIME types.
      Returns:
      the MIME type for the FileObject, or null if the FileObject is unrecognized. It may return content/unknown instead of null. It is possible for the resulting MIME type to not be a member of given withinMIMETypes list.
      Since:
      7.50
    • getSize

      public abstract long getSize()
      Get the size of the file.
      Returns:
      the size of the file in bytes or zero if the file does not contain data (does not exist or is a folder).
    • getInputStream

      public abstract InputStream getInputStream() throws FileNotFoundException
      Get input stream.
      Returns:
      an input stream to read the contents of this file
      Throws:
      FileNotFoundException - if the file does not exists, is a folder rather than a regular file or is invalid
    • asBytes

      public byte[] asBytes() throws IOException
      Reads the full content of the file object and returns it as array of bytes.
      Returns:
      array of bytes
      Throws:
      IOException - in case the content cannot be fully read
      Since:
      7.21
    • asText

      public String asText(String encoding) throws IOException
      Reads the full content of the file object and returns it as string.
      Parameters:
      encoding - the encoding to use
      Returns:
      string representing the content of the file
      Throws:
      IOException - in case the content cannot be fully read
      Since:
      7.21
    • asText

      public String asText() throws IOException
      Reads the full content of the file object and returns it as string. This is similar to calling asText(java.lang.String) with default system encoding.
      Returns:
      string representing the content of the file
      Throws:
      IOException - in case the content cannot be fully read
      Since:
      7.21
    • asLines

      public List<String> asLines() throws IOException
      Reads the full content of the file line by line with default system encoding. Typical usage is in for loops:
       for (String line : fo.asLines()) {
         // do something
       }
       

      The list is optimized for iterating line by line, other operations, like accessing all the lines or counting the number of its lines may be suboptimal.

      Returns:
      list of strings representing the content of the file
      Throws:
      IOException - in case the content cannot be fully read
      Since:
      7.21
    • asLines

      public List<String> asLines(String encoding) throws IOException
      Reads the full content of the file line by line. Typical usage is in for loops:
       for (String line : fo.asLines("UTF-8")) {
         // do something
       }
       

      The list is optimized for iterating line by line, other operations, like accessing all the lines or counting the number of its lines may be suboptimal.

      Parameters:
      encoding - the encoding to use
      Returns:
      list of strings representing the content of the file
      Throws:
      IOException - in case the content cannot be fully read
      Since:
      7.21
    • getOutputStream

      public abstract OutputStream getOutputStream(FileLock lock) throws IOException
      Get output stream.
      Parameters:
      lock - the lock that belongs to this file (obtained by a call to lock())
      Returns:
      output stream to overwrite the contents of this file
      Throws:
      IOException - if an error occures (the file is invalid, etc.)
    • getOutputStream

      public final OutputStream getOutputStream() throws FileAlreadyLockedException, IOException
      Get output stream. This method does its best even when this file object is invalid - since version 9.23 it tries to recreate the parent hierarchy and really open the stream.
      Returns:
      output stream to overwrite the contents of this file
      Throws:
      IOException - if an error occurs
      FileAlreadyLockedException - if the file is already locked
      Since:
      6.6
    • lock

      public abstract FileLock lock() throws IOException
      Lock this file.
      Returns:
      lock that can be used to perform various modifications on the file
      Throws:
      FileAlreadyLockedException - if the file is already locked
      IOException - (UserQuestionException) in case when the lock cannot be obtained now, but the underlaying implementation is able to do it after some complex/dangerous/long-lasting operation and request confirmation from the user
    • isLocked

      public boolean isLocked()
      Test if file is locked
      Returns:
      true if file is locked
      Since:
      7.3
    • setImportant

      @Deprecated public abstract void setImportant(boolean b)
      Deprecated.
      No longer used. Instead use SharabilityQuery.
      Indicate whether this file is important from a user perspective. This method allows a filesystem to distingush between important and unimportant files when this distinction is possible.

      For example: Java sources have important .java files and unimportant .class files. If the filesystem provides an "archive" feature it should archive only .java files.

      Parameters:
      b - true if the file should be considered important
    • getChildren

      public abstract FileObject[] getChildren()
      Get all children of this folder (files and subfolders). If the file does not have children (does not exist or is not a folder) then an empty array should be returned. No particular order is assumed.
      Returns:
      array of direct children
      See Also:
    • getChildren

      public Enumeration<? extends FileObject> getChildren(boolean rec)
      Enumerate all children of this folder. If the children should be enumerated recursively, first all direct children are listed; then children of direct subfolders; and so on.
      Parameters:
      rec - whether to enumerate recursively
      Returns:
      enumeration of type FileObject
    • getFolders

      public Enumeration<? extends FileObject> getFolders(boolean rec)
      Enumerate the subfolders of this folder.
      Parameters:
      rec - whether to recursively list subfolders
      Returns:
      enumeration of type FileObject (satisfying isFolder())
    • getData

      public Enumeration<? extends FileObject> getData(boolean rec)
      Enumerate all data files in this folder.
      Parameters:
      rec - whether to recursively search subfolders
      Returns:
      enumeration of type FileObject (satisfying isData())
    • getFileObject

      public abstract FileObject getFileObject(String name, String ext)
      Retrieve file or folder contained in this folder by name. Note that neither file nor folder is created on disk.
      Parameters:
      name - basename of the file or folder (in this folder)
      ext - extension of the file; null or "" if the file should have no extension or if folder is requested
      Returns:
      the object representing this file or null if the file or folder does not exist
      Throws:
      IllegalArgumentException - if this is not a folder
    • getFileObject

      public FileObject getFileObject(String relativePath)
      Retrieve file or folder relative to a current folder, with a given relative path. Note that neither file nor folder is created on disk. This method isn't final since revision 1.93. Since 7.45 common implementations of this method accept also ".." which is interpreted as a reference to parent.
      Parameters:
      relativePath - is just basename of the file or (since 4.16) the relative path delimited by '/'
      Returns:
      the object representing this file or null if the file or folder does not exist
      Throws:
      IllegalArgumentException - if this is not a folder
    • getFileObject

      public FileObject getFileObject(String relativePath, boolean onlyExisting)
      Retrieve file or folder relative to a current folder, with a given relative path. Note that neither file nor folder is created on disk. This method isn't final since revision 1.93. Since 7.45 common implementations of this method accept also ".." which is interpreted as a reference to parent.
      Parameters:
      relativePath - is just basename of the file or (since 4.16) the relative path delimited by '/'
      onlyExisting - if false then a non-null (but invalid file object is returned even if it doesn't exist
      Returns:
      the object representing requested file or null (when onlyExisting is true) if the file or folder does not exist
      Throws:
      IllegalArgumentException - if this is not a folder
      Since:
      9.23
    • createFolder

      public abstract FileObject createFolder(String name) throws IOException
      Create a new folder below this one with the specified name. Fires FileChangeListener.fileFolderCreated(org.openide.filesystems.FileEvent).
      Parameters:
      name - the name of folder to create. Periods in name are allowed (but no slashes).
      Returns:
      the new folder
      Throws:
      IOException - if the folder cannot be created (e.g. already exists), or if this is not a folder
      See Also:
    • createData

      public abstract FileObject createData(String name, String ext) throws IOException
      Create new data file in this folder with the specified name. Fires FileChangeListener.fileDataCreated(org.openide.filesystems.FileEvent).
      Parameters:
      name - the name of data object to create (can contain a period, but no slashes)
      ext - the extension of the file (or null or "")
      Returns:
      the new data file object
      Throws:
      IOException - if the file cannot be created (e.g. already exists), or if this is not a folder
      See Also:
    • createData

      public FileObject createData(String name) throws IOException
      Create new data file in this folder with the specified name. Fires FileChangeListener.fileDataCreated(org.openide.filesystems.FileEvent).
      Parameters:
      name - the name of data object to create (can contain a period, but no slashes)
      Returns:
      the new data file object
      Throws:
      IOException - if the file cannot be created (e.g. already exists), or if this is not a folder
      Since:
      1.17
      See Also:
    • createAndOpen

      public OutputStream createAndOpen(String name) throws IOException
      Creates new file in this folder and immediately opens it for writing. This method prevents possible race condition which can happen when using the createData(java.lang.String) method. Using that method makes it possible for someone to read the content of the newly created file before its content is written. This method does its best to eliminate such race condition.

      This method usually delivers both, data created and changed events. Preferably it delivers them asynchronously. The assumption is that the file will be (at least partially) written before the listeners start to process the first event. The safety is additionally ensured by mutual exclusion between output and input streams for the same file (any call to getInputStream() will be blocked for at least two seconds if there is existing open output stream). If you finish writing the content of your file in those two seconds, you can be sure, nobody will have read its content yet.

      Parameters:
      name - name of file to create with its extension
      Returns:
      output stream to use to write content of the file
      Throws:
      IOException - if the file cannot be created (e.g. already exists), or if this is not a folder
      Since:
      7.41
    • isReadOnly

      @Deprecated public abstract boolean isReadOnly()
      Deprecated.
      Please use the canWrite().
      Test whether this file can be written to or not.

      The value returned from this method should indicate the capabilities of the file from the point of view of users of the FileObject's API, the actual state of the file on a disk does not matter if the implementation of the filesystem can change it when requested.

      The result returned from this method should be tight together with the expected behaviour of getOutputStream. If it is likely that the method successfully returns a stream that can be written to, let the isReadOnly return false.

      Also other fileobject methods like delete are suggested to be connected to result of this method. If not read only, then it can be deleted, etc.

      It is a good idea to call this method before attempting to perform any operation on the FileObject that might throw an IOException simply because it is read-only. If isReadOnly returns true, the operation may be skipped, or the user notified that it cannot be done. However it is often desirable for the user to be able to continue the operation in case the filesystem supports making a file writable. In this case calling code should:

      1. Call lock() and catch any exception thrown.
      2. Then:
        • If no exception is thrown, proceed with the operation.
        • If a UserQuestionException is thrown, call UserQuestionException#confirmed on it (asynchronously - do not block any important threads). If true, proceed with the operation. If false, exit. If an IOException is thrown, notify it and exit.
        • If another IOException is thrown, call isReadOnly(). If true, ignore the exception (it is expected). If false, notify it.
        In either case, exit.
      Returns:
      true if file is read-only
    • canWrite

      public boolean canWrite()
      Tests if this file can be written to.

      The default implementation simply uses java.io.File.canWrite if there exists conversion to java.io.File (see FileUtil.toFile(org.openide.filesystems.FileObject)). If conversion is not possible, then deprecated method isReadOnly() is used.

      Returns:
      true if this file can be written, false if not.
      Since:
      3.31
    • canRead

      public boolean canRead()
      Tests if this file can be read.

      The default implementation simply uses java.io.File.canRead if there exists conversion to java.io.File (see FileUtil.toFile(org.openide.filesystems.FileObject)). If conversion is not possible, then true is returned.

      Returns:
      true if this file can be read, false if not.
      Since:
      3.31
    • canRevert

      public final boolean canRevert()
      Checks whether this file can be reverted to a pristine state.
      Returns:
      whether revert() might do something
      Since:
      7.55
    • revert

      public final void revert() throws IOException
      Revert this file to a pristine state. Generally only meaningful for files on the system filesystem (layers + user directory): if the file is defined in a layer but modified in the user directory, it is reset; if it is defined only in the user directory, it is deleted. If canRevert() is false, does nothing. Note that while content can be reset, it may not be possible to reset attributes.

      Implementors: for historical reasons this method checks getAttribute(java.lang.String) for a special attribute named removeWritables which must be of type Callable<Void>. If present, the file is considered modified.

      Throws:
      IOException
      Since:
      7.55
    • refresh

      public void refresh(boolean expected)
      Should check for external modifications. For folders it should reread the content of disk, for data file it should check for the last time the file has been modified.
      Parameters:
      expected - should the file events be marked as expected change or not?
      See Also:
    • refresh

      public void refresh()
      Should check for external modifications. For folders it should reread the content of disk, for data file it should check for the last time the file has been modified.

      The file events are marked as unexpected.

    • getURL

      @Deprecated public final URL getURL() throws FileStateInvalidException
      Deprecated.
      Use toURL() instead.
      Throws:
      FileStateInvalidException - never
    • toURL

      public final URL toURL()
      Get URL that can be used to access this file. If the file object does not correspond to a disk file or JAR entry, the URL will only be usable within NetBeans as it uses a special protocol handler. Otherwise an attempt is made to produce an external URL.
      Returns:
      URL of this file object
      Since:
      7.57
      See Also:
    • toURI

      public final URI toURI()
      Gets a URI for this file. Similar to toURL().
      Returns:
      an absolute URI representing this file location
      Since:
      7.57
    • isVirtual

      public boolean isVirtual()
      Tests if file really exists or is missing. Some operation on it may be restricted.
      Returns:
      true indicates that the file is missing.
      Since:
      1.9
    • isSymbolicLink

      public boolean isSymbolicLink() throws IOException
      Check whether this FileObject is a symbolic link. The default implementation returns false, but on filesystems that support symbolic links this method should be overriden.
      Returns:
      True if this FileObject represents a symbolic link, false otherwise.
      Throws:
      IOException - If some I/O problem occurs.
      Since:
      openide.filesystem/9.4
    • readSymbolicLink

      public FileObject readSymbolicLink() throws IOException
      Read symbolic link. If this FileObject represents a symbolic link, return a FileObject it refers to, or null if the referred file or directory does not exist. If this FileObject doesn't represent a symbolic link, the return value is undefined. The default implementation returns null, but on filesystems that support symbolic links this method should be overriden.
      Returns:
      The referred FileObject, or null if it is not available.
      Throws:
      IOException - If some I/O problem occurs.
      Since:
      openide.filesystem/9.4
    • readSymbolicLinkPath

      public String readSymbolicLinkPath() throws IOException
      Read symbolic link path. If this FileObject represents a symbolic link, return the path it refers to, which can be absolute or relative. If this FileObject doesn't represent a symbolic link, the return value is undefined. The default implementation returns this FileObject's path, but on filesystems that support symbolic links this method should be overriden.
      Returns:
      The referred FileObject path.
      Throws:
      IOException - If some I/O problem occurs.
      Since:
      openide.filesystem/9.4
    • getCanonicalFileObject

      public FileObject getCanonicalFileObject() throws IOException
      Return a FileObject with path where all symbolic links are resolved. The default implementation returns this object, but on filesystems that support symbolic links this method should be overriden.
      Returns:
      The FileObject with path where all symlinks are resolved, or null if it doesn't exist.
      Throws:
      IOException - If some I/O problem occurs.
      Since:
      openide.filesystem/9.4