Module xaos.core

Interface AsynchronousIO

    • Method Detail

      • createDirectories

        CompletionStage<Void> createDirectories​(Path dir,
                                                FileAttribute<?>... attrs)
        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.
        Parameters:
        dir - The pathname of the file to be created.
        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

        CompletionStage<Void> createDirectory​(Path dir,
                                              FileAttribute<?>... attrs)
        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.
        Parameters:
        dir - The pathname of the directory to be created.
        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

        CompletionStage<Void> createFile​(Path file,
                                         FileAttribute<?>... attrs)
        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.
        Parameters:
        file - The pathname of the file to be created.
        attrs - An optional list of file attributes to set atomically when creating the file.
        Returns:
        An exceptionally completed CompletionStage in case the file already exists, or an exception is thrown.
      • delete

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

        CompletionStage<Void> deleteTree​(Path root)
        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.
        Parameters:
        root - The path to the file tree root to be deleted.
        Returns:
        An exceptionally completed CompletionStage in case an exception is thrown.
      • readBinaryFile

        CompletionStage<byte[]> readBinaryFile​(Path file)
        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.
        Parameters:
        file - The pathname of the file to be read.
        Returns:
        A CompletionStage containing the read content as a byte array or, if an I/O error occurs, the encountered error.
      • readTextFile

        CompletionStage<String> readTextFile​(Path file,
                                             Charset charset)
        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.
        Parameters:
        file - The pathname of the file to be read.
        charset - The Charset used.
        Returns:
        A CompletionStage containing the read content as a string or, if an I/O error occurs, the encountered error.
      • readUTF8File

        default CompletionStage<String> readUTF8File​(Path file)
        Reads the contents of an UTF8-encoded 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.
        Parameters:
        file - The pathname of the file to be read.
        Returns:
        A CompletionStage containing the read content as a string or, if an I/O error occurs, the encountered error.
      • writeBinaryFile

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

        CompletionStage<Void> writeTextFile​(Path file,
                                            String content,
                                            Charset charset)
        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.
        Parameters:
        file - The pathname of the file to be created.
        content - The String to be written into the file.
        charset - The Charset used.
        Returns:
        An exceptionally completed CompletionStage in case an exception is thrown.
      • writeUTF8File

        default CompletionStage<Void> writeUTF8File​(Path file,
                                                    String content)
        Writes UTF8-encoded text to disk. If an I/O error occurs, the returned completion stage is completed exceptionally with the encountered error.
        Parameters:
        file - The pathname of the file to be created.
        content - The String to be written into the file.
        Returns:
        An exceptionally completed CompletionStage in case an exception is thrown.