Module xaos.ui

Class TreeDirectoryAsynchronousIO<I,​T>

    • Method Detail

      • createDirectories

        public CompletionStage<Void> createDirectories​(Path dir,
                                                       I initiator,
                                                       FileAttribute<?>... attrs)
        Description copied from interface: InitiatorAsynchronousIO
        Create a new directory by creating all nonexistent parent directories first. If an I/O error occurs, the returned completion stage is completed exceptionally with the encountered error.
        Specified by:
        createDirectories in interface InitiatorAsynchronousIO<I>
        Parameters:
        dir - The pathname of the file to be created.
        initiator - The initiator of the operation.
        attrs - An optional list of file attributes to set atomically when creating the directory.
        Returns:
        An exceptionally completed CompletionStage in case of an exception is thrown.
      • createDirectory

        public CompletionStage<Void> createDirectory​(Path dir,
                                                     I initiator,
                                                     FileAttribute<?>... attrs)
        Description copied from interface: InitiatorAsynchronousIO
        Creates a directory. If the directory already exists, or its parent directory does not exist, or another I/O error occurs, the returned completion stage is completed exceptionally with the encountered error.
        Specified by:
        createDirectory in interface InitiatorAsynchronousIO<I>
        Parameters:
        dir - The pathname of the directory to be created.
        initiator - The initiator of the operation.
        attrs - An optional list of file attributes to set atomically when creating the directory.
        Returns:
        An exceptionally completed CompletionStage in case the directory already exists, or its parent directory does not exist, or an exception is thrown.
      • createFile

        public CompletionStage<Void> createFile​(Path file,
                                                I initiator,
                                                FileAttribute<?>... attrs)
        Description copied from interface: InitiatorAsynchronousIO
        Creates an empty file. If file already exists or an I/O error occurs, the returned completion stage is completed exceptionally with the encountered error.
        Specified by:
        createFile in interface InitiatorAsynchronousIO<I>
        Parameters:
        file - The pathname of the file to be created.
        initiator - The initiator of the operation.
        attrs - An optional list of file attributes to set atomically when creating the directory.
        Returns:
        An exceptionally completed CompletionStage in case the file already exists, or an exception is thrown.
      • delete

        public CompletionStage<Void> delete​(Path path,
                                            I initiator)
        Description copied from interface: InitiatorAsynchronousIO
        Deletes a file or an empty directory. If an I/O error occurs, the returned completion stage is completed exceptionally with the encountered error.
        Specified by:
        delete in interface InitiatorAsynchronousIO<I>
        Parameters:
        path - Pathname of the file or directory to be deleted.
        initiator - The initiator of the operation.
        Returns:
        An exceptionally completed CompletionStage in case an exception is thrown.
      • deleteTree

        public CompletionStage<Void> deleteTree​(Path root,
                                                I initiator)
        Description copied from interface: InitiatorAsynchronousIO
        Deletes a file tree rooted at the given path. If an I/O error occurs, the returned completion stage is completed exceptionally with the encountered error.
        Specified by:
        deleteTree in interface InitiatorAsynchronousIO<I>
        Parameters:
        root - The path to the file tree root to be deleted.
        initiator - The initiator of the operation.
        Returns:
        An exceptionally completed CompletionStage in case an exception is thrown.
      • readBinaryFile

        public CompletionStage<byte[]> readBinaryFile​(Path file,
                                                      I initiator)
        Description copied from interface: InitiatorAsynchronousIO
        Reads the contents of a binary file. The returned completion stage will contain the read content as a byte array or, if an I/O error occurs, it will be completed exceptionally with the encountered error.
        Specified by:
        readBinaryFile in interface InitiatorAsynchronousIO<I>
        Parameters:
        file - The pathname of the file to be read.
        initiator - The initiator of the operation.
        Returns:
        A CompletionStage containing the read content as a byte array or, if an I/O error occurs, the encountered error.
      • readTextFile

        public CompletionStage<String> readTextFile​(Path file,
                                                    Charset charset,
                                                    I initiator)
        Description copied from interface: InitiatorAsynchronousIO
        Reads the contents of a text file. The returned completion stage will contain the read content as a string or, if an I/O error occurs, it will be completed exceptionally with the encountered error.
        Specified by:
        readTextFile in interface InitiatorAsynchronousIO<I>
        Parameters:
        file - The pathname of the file to be read.
        charset - The Charset used.
        initiator - The initiator of the operation.
        Returns:
        A CompletionStage containing the read content as a string or, if an I/O error occurs, the encountered error.
      • writeBinaryFile

        public CompletionStage<Void> writeBinaryFile​(Path file,
                                                     byte[] content,
                                                     I initiator)
        Description copied from interface: InitiatorAsynchronousIO
        Writes binary file to disk. If an I/O error occurs, the returned completion stage is completed exceptionally with the encountered error.
        Specified by:
        writeBinaryFile in interface InitiatorAsynchronousIO<I>
        Parameters:
        file - The pathname of the file to be created.
        content - The bytes to be written into the file.
        initiator - The initiator of the operation.
        Returns:
        An exceptionally completed CompletionStage in case an exception is thrown.
      • writeTextFile

        public CompletionStage<Void> writeTextFile​(Path file,
                                                   String content,
                                                   Charset charset,
                                                   I initiator)
        Description copied from interface: InitiatorAsynchronousIO
        Writes the given string in a text file to disk. If an I/O error occurs, the returned completion stage is completed exceptionally with the encountered error.
        Specified by:
        writeTextFile in interface InitiatorAsynchronousIO<I>
        Parameters:
        file - The pathname of the file to be created.
        content - The String to be written in the file.
        charset - The Charset used.
        initiator - The initiator of the operation.
        Returns:
        An exceptionally completed CompletionStage in case an exception is thrown.