Class FileHandleStream


  • public abstract class FileHandleStream
    extends FileHandle
    A FileHandle intended to be subclassed for the purpose of implementing read() and/or write(boolean). Methods that would manipulate the file instead throw UnsupportedOperationException.
    • Constructor Detail

      • FileHandleStream

        public FileHandleStream​(java.lang.String path)
        Create an Files.FileType.Absolute file at the given location.
    • Method Detail

      • isDirectory

        public boolean isDirectory()
        Description copied from class: FileHandle
        Returns true if this file is a directory. Always returns false for classpath files. On Android, an Files.FileType.Internal handle to an empty directory will return false. On the desktop, an Files.FileType.Internal handle to a directory on the classpath will return false.
        Overrides:
        isDirectory in class FileHandle
      • length

        public long length()
        Description copied from class: FileHandle
        Returns the length in bytes of this file, or 0 if this file is a directory, does not exist, or the size cannot otherwise be determined.
        Overrides:
        length in class FileHandle
      • child

        public FileHandle child​(java.lang.String name)
        Description copied from class: FileHandle
        Returns a handle to the child with the specified name.
        Overrides:
        child in class FileHandle
      • sibling

        public FileHandle sibling​(java.lang.String name)
        Description copied from class: FileHandle
        Returns a handle to the sibling with the specified name.
        Overrides:
        sibling in class FileHandle
      • read

        public java.io.InputStream read()
        Description copied from class: FileHandle
        Returns a stream for reading this file as bytes.
        Overrides:
        read in class FileHandle
      • write

        public java.io.OutputStream write​(boolean overwrite)
        Description copied from class: FileHandle
        Returns a stream for writing to this file. Parent directories will be created if necessary.
        Overrides:
        write in class FileHandle
        Parameters:
        overwrite - If false, this file will be overwritten if it exists, otherwise it will be appended.
      • list

        public FileHandle[] list()
        Description copied from class: FileHandle
        Returns the paths to the children of this directory. Returns an empty list if this file handle represents a file and not a directory. On the desktop, an Files.FileType.Internal handle to a directory on the classpath will return a zero length array.
        Overrides:
        list in class FileHandle
      • delete

        public boolean delete()
        Description copied from class: FileHandle
        Deletes this file or empty directory and returns success. Will not delete a directory that has children.
        Overrides:
        delete in class FileHandle
      • deleteDirectory

        public boolean deleteDirectory()
        Description copied from class: FileHandle
        Deletes this file or directory and all children, recursively.
        Overrides:
        deleteDirectory in class FileHandle
      • copyTo

        public void copyTo​(FileHandle dest)
        Description copied from class: FileHandle
        Copies this file or directory to the specified file or directory. If this handle is a file, then 1) if the destination is a file, it is overwritten, or 2) if the destination is a directory, this file is copied into it, or 3) if the destination doesn't exist, FileHandle.mkdirs() is called on the destination's parent and this file is copied into it with a new name. If this handle is a directory, then 1) if the destination is a file, GdxRuntimeException is thrown, or 2) if the destination is a directory, this directory is copied into it recursively, overwriting existing files, or 3) if the destination doesn't exist, FileHandle.mkdirs() is called on the destination and this directory is copied into it recursively.
        Overrides:
        copyTo in class FileHandle
      • moveTo

        public void moveTo​(FileHandle dest)
        Description copied from class: FileHandle
        Moves this file to the specified file, overwriting the file if it already exists.
        Overrides:
        moveTo in class FileHandle
      • emptyDirectory

        public void emptyDirectory()
        Description copied from class: FileHandle
        Deletes all children of this directory, recursively.
        Overrides:
        emptyDirectory in class FileHandle
      • emptyDirectory

        public void emptyDirectory​(boolean preserveTree)
        Description copied from class: FileHandle
        Deletes all children of this directory, recursively. Optionally preserving the folder structure.
        Overrides:
        emptyDirectory in class FileHandle