Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code LNG204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.
java.nio.channels

Interface SeekableByteChannel

    • Method Detail

      • read

        int read(ByteBuffer dst)
                 throws IOException
        Reads a sequence of bytes from this channel into the given buffer.

        Bytes are read starting at this channel's current position, and then the position is updated with the number of bytes actually read. Otherwise this method behaves exactly as specified in the ReadableByteChannel interface.

        Specified by:
        read in interface ReadableByteChannel
        Parameters:
        dst - The buffer into which bytes are to be transferred
        Returns:
        The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream
        Throws:
        ClosedChannelException - If this channel is closed
        AsynchronousCloseException - If another thread closes this channel while the read operation is in progress
        ClosedByInterruptException - If another thread interrupts the current thread while the read operation is in progress, thereby closing the channel and setting the current thread's interrupt status
        IOException - If some other I/O error occurs
      • write

        int write(ByteBuffer src)
                  throws IOException
        Writes a sequence of bytes to this channel from the given buffer.

        Bytes are written starting at this channel's current position, unless the channel is connected to an entity such as a file that is opened with the APPEND option, in which case the position is first advanced to the end. The entity to which the channel is connected is grown, if necessary, to accommodate the written bytes, and then the position is updated with the number of bytes actually written. Otherwise this method behaves exactly as specified by the WritableByteChannel interface.

        Specified by:
        write in interface WritableByteChannel
        Parameters:
        src - The buffer from which bytes are to be retrieved
        Returns:
        The number of bytes written, possibly zero
        Throws:
        ClosedChannelException - If this channel is closed
        AsynchronousCloseException - If another thread closes this channel while the write operation is in progress
        ClosedByInterruptException - If another thread interrupts the current thread while the write operation is in progress, thereby closing the channel and setting the current thread's interrupt status
        IOException - If some other I/O error occurs
      • position

        long position()
                      throws IOException
        Returns this channel's position.
        Returns:
        This channel's position, a non-negative integer counting the number of bytes from the beginning of the entity to the current position
        Throws:
        ClosedChannelException - If this channel is closed
        IOException - If some other I/O error occurs
      • position

        SeekableByteChannel position(long newPosition)
                                     throws IOException
        Sets this channel's position.

        Setting the position to a value that is greater than the current size is legal but does not change the size of the entity. A later attempt to read bytes at such a position will immediately return an end-of-file indication. A later attempt to write bytes at such a position will cause the entity to grow to accommodate the new bytes; the values of any bytes between the previous end-of-file and the newly-written bytes are unspecified.

        Setting the channel's position is not recommended when connected to an entity, typically a file, that is opened with the APPEND option. When opened for append, the position is first advanced to the end before writing.

        Parameters:
        newPosition - The new position, a non-negative integer counting the number of bytes from the beginning of the entity
        Returns:
        This channel
        Throws:
        ClosedChannelException - If this channel is closed
        IllegalArgumentException - If the new position is negative
        IOException - If some other I/O error occurs
      • size

        long size()
                  throws IOException
        Returns the current size of entity to which this channel is connected.
        Returns:
        The current size, measured in bytes
        Throws:
        ClosedChannelException - If this channel is closed
        IOException - If some other I/O error occurs
      • truncate

        SeekableByteChannel truncate(long size)
                                     throws IOException
        Truncates the entity, to which this channel is connected, to the given size.

        If the given size is less than the current size then the entity is truncated, discarding any bytes beyond the new end. If the given size is greater than or equal to the current size then the entity is not modified. In either case, if the current position is greater than the given size then it is set to that size.

        An implementation of this interface may prohibit truncation when connected to an entity, typically a file, opened with the APPEND option.

        Parameters:
        size - The new size, a non-negative byte count
        Returns:
        This channel
        Throws:
        NonWritableChannelException - If this channel was not opened for writing
        ClosedChannelException - If this channel is closed
        IllegalArgumentException - If the new size is negative
        IOException - If some other I/O error occurs

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/nio/channels/SeekableByteChannel.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut