Keine Cache-Version

Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code LNG204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.
java.nio.channels

Interface AsynchronousByteChannel

    • Method Detail

      • read

        <A> void read(ByteBuffer dst,
                    A attachment,
                    CompletionHandler<Integer,? super A> handler)
        Reads a sequence of bytes from this channel into the given buffer.

        This method initiates an asynchronous read operation to read a sequence of bytes from this channel into the given buffer. The handler parameter is a completion handler that is invoked when the read operation completes (or fails). The result passed to the completion handler is the number of bytes read or -1 if no bytes could be read because the channel has reached end-of-stream.

        The read operation may read up to r bytes from the channel, where r is the number of bytes remaining in the buffer, that is, dst.remaining() at the time that the read is attempted. Where r is 0, the read operation completes immediately with a result of 0 without initiating an I/O operation.

        Suppose that a byte sequence of length n is read, where 0 < n <= r. This byte sequence will be transferred into the buffer so that the first byte in the sequence is at index p and the last byte is at index p + n - 1, where p is the buffer's position at the moment the read is performed. Upon completion the buffer's position will be equal to p + n; its limit will not have changed.

        Buffers are not safe for use by multiple concurrent threads so care should be taken to not access the buffer until the operation has completed.

        This method may be invoked at any time. Some channel types may not allow more than one read to be outstanding at any given time. If a thread initiates a read operation before a previous read operation has completed then a ReadPendingException will be thrown.

        Parameters:
        dst - The buffer into which bytes are to be transferred
        attachment - The object to attach to the I/O operation; can be null
        handler - The completion handler
        Throws:
        IllegalArgumentException - If the buffer is read-only
        ReadPendingException - If the channel does not allow more than one read to be outstanding and a previous read has not completed
        ShutdownChannelGroupException - If the channel is associated with a group that has terminated
      • read

        Future<Integer> read(ByteBuffer dst)
        Reads a sequence of bytes from this channel into the given buffer.

        This method initiates an asynchronous read operation to read a sequence of bytes from this channel into the given buffer. The method behaves in exactly the same manner as the read(ByteBuffer,Object,CompletionHandler) method except that instead of specifying a completion handler, this method returns a Future representing the pending result. The Future's get method returns the number of bytes read or -1 if no bytes could be read because the channel has reached end-of-stream.

        Parameters:
        dst - The buffer into which bytes are to be transferred
        Returns:
        A Future representing the result of the operation
        Throws:
        IllegalArgumentException - If the buffer is read-only
        ReadPendingException - If the channel does not allow more than one read to be outstanding and a previous read has not completed
      • write

        <A> void write(ByteBuffer src,
                     A attachment,
                     CompletionHandler<Integer,? super A> handler)
        Writes a sequence of bytes to this channel from the given buffer.

        This method initiates an asynchronous write operation to write a sequence of bytes to this channel from the given buffer. The handler parameter is a completion handler that is invoked when the write operation completes (or fails). The result passed to the completion handler is the number of bytes written.

        The write operation may write up to r bytes to the channel, where r is the number of bytes remaining in the buffer, that is, src.remaining() at the time that the write is attempted. Where r is 0, the write operation completes immediately with a result of 0 without initiating an I/O operation.

        Suppose that a byte sequence of length n is written, where 0 < n <= r. This byte sequence will be transferred from the buffer starting at index p, where p is the buffer's position at the moment the write is performed; the index of the last byte written will be p + n - 1. Upon completion the buffer's position will be equal to p + n; its limit will not have changed.

        Buffers are not safe for use by multiple concurrent threads so care should be taken to not access the buffer until the operation has completed.

        This method may be invoked at any time. Some channel types may not allow more than one write to be outstanding at any given time. If a thread initiates a write operation before a previous write operation has completed then a WritePendingException will be thrown.

        Parameters:
        src - The buffer from which bytes are to be retrieved
        attachment - The object to attach to the I/O operation; can be null
        handler - The completion handler object
        Throws:
        WritePendingException - If the channel does not allow more than one write to be outstanding and a previous write has not completed
        ShutdownChannelGroupException - If the channel is associated with a group that has terminated
      • write

        Future<Integer> write(ByteBuffer src)
        Writes a sequence of bytes to this channel from the given buffer.

        This method initiates an asynchronous write operation to write a sequence of bytes to this channel from the given buffer. The method behaves in exactly the same manner as the write(ByteBuffer,Object,CompletionHandler) method except that instead of specifying a completion handler, this method returns a Future representing the pending result. The Future's get method returns the number of bytes written.

        Parameters:
        src - The buffer from which bytes are to be retrieved
        Returns:
        A Future representing the result of the operation
        Throws:
        WritePendingException - If the channel does not allow more than one write to be outstanding and a previous write has not completed

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-java/nio/channels/AsynchronousByteChannel.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut