Package adams.core.io

Class PlaceholderFile

    • Constructor Summary

      Constructors 
      Constructor Description
      PlaceholderFile()
      Creates a new PlaceholderFile instance by using the given file.
      PlaceholderFile​(File file)
      Creates a new PlaceholderFile instance by using the given file.
      PlaceholderFile​(File parent, String child)
      Creates a new File instance from a parent abstract pathname and a child pathname string.
      PlaceholderFile​(String pathname)
      Creates a new File instance by converting the given pathname string into an abstract pathname.
      PlaceholderFile​(String parent, String child)
      Creates a new File instance from a parent pathname string and a child pathname string.
      PlaceholderFile​(URI uri)
      Creates a new File instance by converting the given file: URI into an abstract pathname.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canExecute()
      Tests whether the application can execute the file denoted by this abstract pathname.
      boolean canRead()
      Tests whether the application can read the file denoted by this abstract pathname.
      boolean canWrite()
      Tests whether the application can modify the file denoted by this abstract pathname.
      PlaceholderFile changeExtension​(String newExt)
      Swaps the current extension with the new one.
      PlaceholderFile changeExtension​(String oldExt, String newExt)
      Swaps the specified old extension with the new one.
      int compareTo​(File pathname)
      Compares two abstract pathnames lexicographically.
      boolean createNewFile()
      Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.
      boolean delete()
      Deletes the file or directory denoted by this abstract pathname.
      void deleteOnExit()
      Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
      boolean exists()
      Tests whether the file or directory denoted by this abstract pathname exists.
      protected String expand​(String path)
      Expands any placeholders, if necessary.
      protected static String fixSeparator​(File file)
      Fixes the separator in the given file, changing backslashes to forward slashes under Linux and vice versa under Windows.
      protected static String fixSeparator​(String path)
      Fixes the separator in the given string, changing backslashes to forward slashes under Linux and vice versa under Windows.
      String getAbsolutePath()
      Returns the absolute pathname string of this abstract pathname.
      String getCanonicalPath()
      Returns the canonical pathname string of this abstract pathname.
      String getExtension()
      Returns the extension, i.e., the string after the last dot.
      String getExtension​(String suffix)
      Returns the extension, i.e., the string after the last dot.
      long getFreeSpace()
      Returns the number of unallocated bytes in the partition named by this abstract path name.
      String getParent()
      Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.
      File getParentFile()
      Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
      long getTotalSpace()
      Returns the size of the partition named by this abstract pathname.
      long getUsableSpace()
      Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname.
      boolean isAbsolute()
      Tests whether this abstract pathname is absolute.
      boolean isDirectory()
      Tests whether the file denoted by this abstract pathname is a directory.
      boolean isFile()
      Tests whether the file denoted by this abstract pathname is a normal file.
      boolean isHidden()
      Tests whether the file named by this abstract pathname is a hidden file.
      static boolean isValid​(PlaceholderFile file)
      Checks whether the placeholer file is valid.
      static boolean isValid​(String file)
      Checks whether the placeholer file is valid.
      long lastModified()
      Returns the time that the file denoted by this abstract pathname was last modified.
      long length()
      Returns the length of the file denoted by this abstract pathname.
      String[] list()
      Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
      String[] list​(String regExp)
      Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname, as long as they match the regular expression.
      PlaceholderFile[] listFiles()
      Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
      PlaceholderFile[] listFiles​(FileFilter filter)
      Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
      PlaceholderFile[] listFiles​(FilenameFilter filter)
      Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
      boolean mkdir()
      Creates the directory named by this abstract pathname.
      boolean renameTo​(File dest)
      Renames the file denoted by this abstract pathname.
      boolean setExecutable​(boolean executable, boolean ownerOnly)
      Sets the owner's or everybody's execute permission for this abstract pathname.
      boolean setLastModified​(long time)
      Sets the last-modified time of the file or directory named by this abstract pathname.
      boolean setReadable​(boolean readable, boolean ownerOnly)
      Sets the owner's or everybody's read permission for this abstract pathname.
      boolean setReadOnly()
      Marks the file or directory named by this abstract pathname so that only read operations are allowed.
      boolean setWritable​(boolean writable, boolean ownerOnly)
      Sets the owner's or everybody's write permission for this abstract pathname.
      Path toPath()
      Turns the file object into a Path object.
      protected PlaceholderFile[] toPlaceholderFiles​(File[] files)
      Turns the regular File objects into PlaceholderFile ones.
    • Constructor Detail

      • PlaceholderFile

        public PlaceholderFile()
        Creates a new PlaceholderFile instance by using the given file.
      • PlaceholderFile

        public PlaceholderFile​(File file)
        Creates a new PlaceholderFile instance by using the given file.
        Parameters:
        file - the file to use
      • PlaceholderFile

        public PlaceholderFile​(String pathname)
        Creates a new File instance by converting the given pathname string into an abstract pathname. If the given string is the empty string, then the result is the empty abstract pathname.
        Parameters:
        pathname - A pathname string
      • PlaceholderFile

        public PlaceholderFile​(String parent,
                               String child)
        Creates a new File instance from a parent pathname string and a child pathname string.

        If parent is null then the new File instance is created as if by invoking the single-argument File constructor on the given child pathname string.

        Otherwise the parent pathname string is taken to denote a directory, and the child pathname string is taken to denote either a directory or a file. If the child pathname string is absolute then it is converted into a relative pathname in a system-dependent way. If parent is the empty string then the new File instance is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.

        Parameters:
        parent - The parent pathname string
        child - The child pathname string
      • PlaceholderFile

        public PlaceholderFile​(File parent,
                               String child)
        Creates a new File instance from a parent abstract pathname and a child pathname string.

        If parent is null then the new File instance is created as if by invoking the single-argument File constructor on the given child pathname string.

        Otherwise the parent abstract pathname is taken to denote a directory, and the child pathname string is taken to denote either a directory or a file. If the child pathname string is absolute then it is converted into a relative pathname in a system-dependent way. If parent is the empty abstract pathname then the new File instance is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.

        Parameters:
        parent - The parent abstract pathname
        child - The child pathname string
      • PlaceholderFile

        public PlaceholderFile​(URI uri)
        Creates a new File instance by converting the given file: URI into an abstract pathname.

        The exact form of a file: URI is system-dependent, hence the transformation performed by this constructor is also system-dependent.

        For a given abstract pathname f it is guaranteed that

        new File( f.toURI()).equals( f.getAbsoluteFile())
        so long as the original abstract pathname, the URI, and the new abstract pathname are all created in (possibly different invocations of) the same Java virtual machine. This relationship typically does not hold, however, when a file: URI that is created in a virtual machine on one operating system is converted into an abstract pathname in a virtual machine on a different operating system.
        Parameters:
        uri - An absolute, hierarchical URI with a scheme equal to "file", a non-empty path component, and undefined authority, query, and fragment components
    • Method Detail

      • canExecute

        public boolean canExecute()
        Tests whether the application can execute the file denoted by this abstract pathname.
        Overrides:
        canExecute in class File
        Returns:
        true if and only if the abstract pathname exists and the application is allowed to execute the file
      • canRead

        public boolean canRead()
        Tests whether the application can read the file denoted by this abstract pathname.
        Overrides:
        canRead in class File
        Returns:
        true if and only if the file specified by this abstract pathname exists and can be read by the application; false otherwise
      • canWrite

        public boolean canWrite()
        Tests whether the application can modify the file denoted by this abstract pathname.
        Overrides:
        canWrite in class File
        Returns:
        true if and only if the file system actually contains a file denoted by this abstract pathname and the application is allowed to write to the file; false otherwise.
      • compareTo

        public int compareTo​(File pathname)
        Compares two abstract pathnames lexicographically. The ordering defined by this method depends upon the underlying system. On UNIX systems, alphabetic case is significant in comparing pathnames; on Microsoft Windows systems it is not.
        Specified by:
        compareTo in interface Comparable<File>
        Overrides:
        compareTo in class File
        Parameters:
        pathname - The abstract pathname to be compared to this abstract pathname
        Returns:
        Zero if the argument is equal to this abstract pathname, a value less than zero if this abstract pathname is lexicographically less than the argument, or a value greater than zero if this abstract pathname is lexicographically greater than the argument
      • createNewFile

        public boolean createNewFile()
                              throws IOException
        Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file.

        Note: this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. The FileLock facility should be used instead.

        Overrides:
        createNewFile in class File
        Returns:
        true if the named file does not exist and was successfully created; false if the named file already exists
        Throws:
        IOException - If an I/O error occurred
      • delete

        public boolean delete()
        Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted.
        Overrides:
        delete in class File
        Returns:
        true if and only if the file or directory is successfully deleted; false otherwise
      • deleteOnExit

        public void deleteOnExit()
        Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates. Files (or directories) are deleted in the reverse order that they are registered. Invoking this method to delete a file or directory that is already registered for deletion has no effect. Deletion will be attempted only for normal termination of the virtual machine, as defined by the Java Language Specification.

        Once deletion has been requested, it is not possible to cancel the request. This method should therefore be used with care.

        Note: this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. The FileLock facility should be used instead.

        Overrides:
        deleteOnExit in class File
      • exists

        public boolean exists()
        Tests whether the file or directory denoted by this abstract pathname exists.
        Overrides:
        exists in class File
        Returns:
        true if and only if the file or directory denoted by this abstract pathname exists; false otherwise
      • getCanonicalPath

        public String getCanonicalPath()
                                throws IOException
        Returns the canonical pathname string of this abstract pathname.

        A canonical pathname is both absolute and unique. The precise definition of canonical form is system-dependent. This method first converts this pathname to absolute form if necessary, as if by invoking the getAbsolutePath() method, and then maps it to its unique form in a system-dependent way. This typically involves removing redundant names such as "." and ".." from the pathname, resolving symbolic links (on UNIX platforms), and converting drive letters to a standard case (on Microsoft Windows platforms).

        Every pathname that denotes an existing file or directory has a unique canonical form. Every pathname that denotes a nonexistent file or directory also has a unique canonical form. The canonical form of the pathname of a nonexistent file or directory may be different from the canonical form of the same pathname after the file or directory is created. Similarly, the canonical form of the pathname of an existing file or directory may be different from the canonical form of the same pathname after the file or directory is deleted.

        Overrides:
        getCanonicalPath in class File
        Returns:
        The canonical pathname string denoting the same file or directory as this abstract pathname
        Throws:
        IOException - If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries
      • getFreeSpace

        public long getFreeSpace()
        Returns the number of unallocated bytes in the partition named by this abstract path name.

        The returned number of unallocated bytes is a hint, but not a guarantee, that it is possible to use most or any of these bytes. The number of unallocated bytes is most likely to be accurate immediately after this call. It is likely to be made inaccurate by any external I/O operations including those made on the system outside of this virtual machine. This method makes no guarantee that write operations to this file system will succeed.

        Overrides:
        getFreeSpace in class File
        Returns:
        The number of unallocated bytes on the partition 0L if the abstract pathname does not name a partition. This value will be less than or equal to the total file system size returned by getTotalSpace().
      • getTotalSpace

        public long getTotalSpace()
        Returns the size of the partition named by this abstract pathname.
        Overrides:
        getTotalSpace in class File
        Returns:
        The size, in bytes, of the partition or 0L if this abstract pathname does not name a partition
      • getUsableSpace

        public long getUsableSpace()
        Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname. When possible, this method checks for write permissions and other operating system restrictions and will therefore usually provide a more accurate estimate of how much new data can actually be written than getFreeSpace().

        The returned number of available bytes is a hint, but not a guarantee, that it is possible to use most or any of these bytes. The number of unallocated bytes is most likely to be accurate immediately after this call. It is likely to be made inaccurate by any external I/O operations including those made on the system outside of this virtual machine. This method makes no guarantee that write operations to this file system will succeed.

        Overrides:
        getUsableSpace in class File
        Returns:
        The number of available bytes on the partition or 0L if the abstract pathname does not name a partition. On systems where this information is not available, this method will be equivalent to a call to getFreeSpace().
      • isAbsolute

        public boolean isAbsolute()
        Tests whether this abstract pathname is absolute. The definition of absolute pathname is system dependent. On UNIX systems, a pathname is absolute if its prefix is "/". On Microsoft Windows systems, a pathname is absolute if its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\".
        Overrides:
        isAbsolute in class File
        Returns:
        true if this abstract pathname is absolute, false otherwise
      • isDirectory

        public boolean isDirectory()
        Tests whether the file denoted by this abstract pathname is a directory.
        Overrides:
        isDirectory in class File
        Returns:
        true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise
      • isFile

        public boolean isFile()
        Tests whether the file denoted by this abstract pathname is a normal file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.
        Overrides:
        isFile in class File
        Returns:
        true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise
      • isHidden

        public boolean isHidden()
        Tests whether the file named by this abstract pathname is a hidden file. The exact definition of hidden is system-dependent. On UNIX systems, a file is considered to be hidden if its name begins with a period character ('.'). On Microsoft Windows systems, a file is considered to be hidden if it has been marked as such in the filesystem.
        Overrides:
        isHidden in class File
        Returns:
        true if and only if the file denoted by this abstract pathname is hidden according to the conventions of the underlying platform
      • lastModified

        public long lastModified()
        Returns the time that the file denoted by this abstract pathname was last modified.
        Overrides:
        lastModified in class File
        Returns:
        A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs
      • length

        public long length()
        Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.
        Overrides:
        length in class File
        Returns:
        The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist. Some operating systems may return 0L for pathnames denoting system-dependent entities such as devices or pipes.
      • list

        public String[] list()
        Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

        If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of strings is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path.

        There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

        Overrides:
        list in class File
        Returns:
        An array of strings naming the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
      • list

        public String[] list​(String regExp)
        Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname, as long as they match the regular expression.

        If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of strings is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path.

        There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

        Parameters:
        regExp - The regular expression that the filenames must match.
        Returns:
        An array of strings naming the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
      • toPlaceholderFiles

        protected PlaceholderFile[] toPlaceholderFiles​(File[] files)
        Turns the regular File objects into PlaceholderFile ones.
        Parameters:
        files - the files to convert
        Returns:
        the converted files
      • listFiles

        public PlaceholderFile[] listFiles()
        Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.

        If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of File objects is returned, one for each file or directory in the directory. Pathnames denoting the directory itself and the directory's parent directory are not included in the result. Each resulting abstract pathname is constructed from this abstract pathname using the File(File, String) constructor. Therefore if this pathname is absolute then each resulting pathname is absolute; if this pathname is relative then each resulting pathname will be relative to the same directory.

        There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

        Overrides:
        listFiles in class File
        Returns:
        An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
      • listFiles

        public PlaceholderFile[] listFiles​(FilenameFilter filter)
        Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. The behavior of this method is the same as that of the listFiles() method, except that the pathnames in the returned array must satisfy the filter. If the given filter is null then all pathnames are accepted. Otherwise, a pathname satisfies the filter if and only if the value true results when the FilenameFilter.accept(java.io.File, java.lang.String) method of the filter is invoked on this abstract pathname and the name of a file or directory in the directory that it denotes.
        Overrides:
        listFiles in class File
        Parameters:
        filter - A filename filter
        Returns:
        An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
        Throws:
        SecurityException - If a security manager exists and its SecurityManager.checkRead(java.lang.String) method denies read access to the directory
        Since:
        1.2
      • listFiles

        public PlaceholderFile[] listFiles​(FileFilter filter)
        Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. The behavior of this method is the same as that of the listFiles() method, except that the pathnames in the returned array must satisfy the filter. If the given filter is null then all pathnames are accepted. Otherwise, a pathname satisfies the filter if and only if the value true results when the FileFilter.accept(java.io.File) method of the filter is invoked on the pathname.
        Overrides:
        listFiles in class File
        Parameters:
        filter - A file filter
        Returns:
        An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
        Throws:
        SecurityException - If a security manager exists and its SecurityManager.checkRead(java.lang.String) method denies read access to the directory
        Since:
        1.2
      • mkdir

        public boolean mkdir()
        Creates the directory named by this abstract pathname.
        Overrides:
        mkdir in class File
        Returns:
        true if and only if the directory was created; false otherwise
      • renameTo

        public boolean renameTo​(File dest)
        Renames the file denoted by this abstract pathname.

        Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists. The return value should always be checked to make sure that the rename operation was successful.

        Overrides:
        renameTo in class File
        Parameters:
        dest - The new abstract pathname for the named file
        Returns:
        true if and only if the renaming succeeded; false otherwise
      • setExecutable

        public boolean setExecutable​(boolean executable,
                                     boolean ownerOnly)
        Sets the owner's or everybody's execute permission for this abstract pathname.
        Overrides:
        setExecutable in class File
        Parameters:
        executable - If true, sets the access permission to allow execute operations; if false to disallow execute operations
        ownerOnly - If true, the execute permission applies only to the owner's execute permission; otherwise, it applies to everybody. If the underlying file system can not distinguish the owner's execute permission from that of others, then the permission will apply to everybody, regardless of this value.
        Returns:
        true if and only if the operation succeeded. The operation will fail if the user does not have permission to change the access permissions of this abstract pathname. If executable is false and the underlying file system does not implement an execute permission, then the operation will fail.
      • setLastModified

        public boolean setLastModified​(long time)
        Sets the last-modified time of the file or directory named by this abstract pathname.

        All platforms support file-modification times to the nearest second, but some provide more precision. The argument will be truncated to fit the supported precision. If the operation succeeds and no intervening operations on the file take place, then the next invocation of the lastModified() method will return the (possibly truncated) time argument that was passed to this method.

        Overrides:
        setLastModified in class File
        Parameters:
        time - The new last-modified time, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)
        Returns:
        true if and only if the operation succeeded; false otherwise
      • setReadable

        public boolean setReadable​(boolean readable,
                                   boolean ownerOnly)
        Sets the owner's or everybody's read permission for this abstract pathname.
        Overrides:
        setReadable in class File
        Parameters:
        readable - If true, sets the access permission to allow read operations; if false to disallow read operations
        ownerOnly - If true, the read permission applies only to the owner's read permission; otherwise, it applies to everybody. If the underlying file system can not distinguish the owner's read permission from that of others, then the permission will apply to everybody, regardless of this value.
        Returns:
        true if and only if the operation succeeded. The operation will fail if the user does not have permission to change the access permissions of this abstract pathname. If readable is false and the underlying file system does not implement a read permission, then the operation will fail.
      • setReadOnly

        public boolean setReadOnly()
        Marks the file or directory named by this abstract pathname so that only read operations are allowed. After invoking this method the file or directory is guaranteed not to change until it is either deleted or marked to allow write access. Whether or not a read-only file or directory may be deleted depends upon the underlying system.
        Overrides:
        setReadOnly in class File
        Returns:
        true if and only if the operation succeeded; false otherwise
      • setWritable

        public boolean setWritable​(boolean writable,
                                   boolean ownerOnly)
        Sets the owner's or everybody's write permission for this abstract pathname.
        Overrides:
        setWritable in class File
        Parameters:
        writable - If true, sets the access permission to allow write operations; if false to disallow write operations
        ownerOnly - If true, the write permission applies only to the owner's write permission; otherwise, it applies to everybody. If the underlying file system can not distinguish the owner's write permission from that of others, then the permission will apply to everybody, regardless of this value.
        Returns:
        true if and only if the operation succeeded. The operation will fail if the user does not have permission to change the access permissions of this abstract pathname.
      • getParent

        public String getParent()
        Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.

        The parent of an abstract pathname consists of the pathname's prefix, if any, and each name in the pathname's name sequence except for the last. If the name sequence is empty then the pathname does not name a parent directory.

        Overrides:
        getParent in class File
        Returns:
        The pathname string of the parent directory named by this abstract pathname, or null if this pathname does not name a parent
      • getParentFile

        public File getParentFile()
        Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.

        The parent of an abstract pathname consists of the pathname's prefix, if any, and each name in the pathname's name sequence except for the last. If the name sequence is empty then the pathname does not name a parent directory.

        Overrides:
        getParentFile in class File
        Returns:
        The abstract pathname of the parent directory named by this abstract pathname, or null if this pathname does not name a parent
        Since:
        1.2
      • expand

        protected String expand​(String path)
        Expands any placeholders, if necessary.
        Parameters:
        path - the path to expand (if necessary)
        Returns:
        the expanded path
      • getAbsolutePath

        public String getAbsolutePath()
        Returns the absolute pathname string of this abstract pathname. This also replaces existing placeholders with the actual values.
        Overrides:
        getAbsolutePath in class File
        Returns:
        The absolute pathname string denoting the same file or directory as this abstract pathname
      • fixSeparator

        protected static String fixSeparator​(File file)
        Fixes the separator in the given file, changing backslashes to forward slashes under Linux and vice versa under Windows.
        Parameters:
        file - the path to process
        Returns:
        the fixed path
      • fixSeparator

        protected static String fixSeparator​(String path)
        Fixes the separator in the given string, changing backslashes to forward slashes under Linux and vice versa under Windows.
        Parameters:
        path - the path to process
        Returns:
        the fixed path
      • isValid

        public static boolean isValid​(String file)
        Checks whether the placeholer file is valid.
        Parameters:
        file - the file to check
        Returns:
        true if valid
      • isValid

        public static boolean isValid​(PlaceholderFile file)
        Checks whether the placeholer file is valid.
        Parameters:
        file - the file to check
        Returns:
        true if valid
      • getExtension

        public String getExtension()
        Returns the extension, i.e., the string after the last dot. If extension is from a compressed file, like "file.tar.gz", this will return only "gz".
        Returns:
        the extension (without the dot), empty string if not available
        See Also:
        getExtension(String)
      • getExtension

        public String getExtension​(String suffix)
        Returns the extension, i.e., the string after the last dot. Skips the suffix (for instance for compressed files, this could be ".gz" or "gz") before locating the next ".".
        Parameters:
        suffix - the suffix to skip. with or without preceding dot, as it gets automatically prepended if missing
        Returns:
        the extension (without the dot), empty string if not available
      • changeExtension

        public PlaceholderFile changeExtension​(String oldExt,
                                               String newExt)
        Swaps the specified old extension with the new one.
        Parameters:
        oldExt - the old extension to replace
        newExt - the new extension to use
        Returns:
        the file with the new extension
      • toPath

        public Path toPath()
        Turns the file object into a Path object.
        Overrides:
        toPath in class File
        Returns:
        the path object