Class SeekableSMBByteChannel

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.ByteChannel, java.nio.channels.Channel, java.nio.channels.ReadableByteChannel, java.nio.channels.SeekableByteChannel, java.nio.channels.WritableByteChannel

    public final class SeekableSMBByteChannel
    extends java.lang.Object
    implements java.nio.channels.SeekableByteChannel
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the current SeekableSMBByteChannel.
      boolean isOpen()
      Determines whether the current SeekableSMBByteChannel is still opened.
      long position()
      Returns the position of the pointer into the SmbRandomAccessFile that is handled by the current instance of SeekableSMBByteChannel
      java.nio.channels.SeekableByteChannel position​(long newPosition)
      Tries to reposition the pointer into the SmbRandomAccessFile that is handled by the current instance of SeekableSMBByteChannel
      int read​(java.nio.ByteBuffer dst)
      Reads the content from the SmbRandomAccessFile handled by the current instance of SeekableSMBByteChannel to the provided ByteBuffer.
      long size()
      Returns the size of the file handled by the current instance of SeekableSMBByteChannel.
      java.nio.channels.SeekableByteChannel truncate​(long size)
      Truncates the SmbRandomAccessFile by setting its length to the provided value.
      int write​(java.nio.ByteBuffer src)
      Writes the content of the provided ByteBuffer into the SmbRandomAccessFile handled by the current instance of SeekableSMBByteChannel.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • read

        public int read​(java.nio.ByteBuffer dst)
                 throws java.io.IOException
        Reads the content from the SmbRandomAccessFile handled by the current instance of SeekableSMBByteChannel to the provided ByteBuffer. The ByteBuffer is written from its current position to its end.
        Specified by:
        read in interface java.nio.channels.ReadableByteChannel
        Specified by:
        read in interface java.nio.channels.SeekableByteChannel
        Parameters:
        dst - ByteBuffer to which to write the data.
        Returns:
        Number of bytes that were read.
        Throws:
        java.io.IOException - If something goes wrong while reading to the file.
      • write

        public int write​(java.nio.ByteBuffer src)
                  throws java.io.IOException
        Writes the content of the provided ByteBuffer into the SmbRandomAccessFile handled by the current instance of SeekableSMBByteChannel. The ByteBuffer is read from its current position to it end.
        Specified by:
        write in interface java.nio.channels.SeekableByteChannel
        Specified by:
        write in interface java.nio.channels.WritableByteChannel
        Parameters:
        src - ByteBuffer from which to read the data.
        Returns:
        Number of bytes that were written.
        Throws:
        java.io.IOException - If something goes wrong while writing to the file.
      • position

        public long position()
                      throws java.io.IOException
        Returns the position of the pointer into the SmbRandomAccessFile that is handled by the current instance of SeekableSMBByteChannel
        Specified by:
        position in interface java.nio.channels.SeekableByteChannel
        Returns:
        newPosition New position within the file.
        Throws:
        java.io.IOException - If something goes wrong while trying to determine file size.
      • size

        public long size()
                  throws java.io.IOException
        Returns the size of the file handled by the current instance of SeekableSMBByteChannel. The size is given in number of bytes.
        Specified by:
        size in interface java.nio.channels.SeekableByteChannel
        Returns:
        size Size of the SMB file.
        Throws:
        java.io.IOException - If something goes wrong while trying to determine file size.
      • position

        public java.nio.channels.SeekableByteChannel position​(long newPosition)
                                                       throws java.io.IOException
        Tries to reposition the pointer into the SmbRandomAccessFile that is handled by the current instance of SeekableSMBByteChannel
        Specified by:
        position in interface java.nio.channels.SeekableByteChannel
        Parameters:
        newPosition - New position within the file.
        Returns:
        Current instance of SeekableSMBByteChannel.
        Throws:
        java.io.IOException - If something goes wrong while trying to determine file size.
      • truncate

        public java.nio.channels.SeekableByteChannel truncate​(long size)
                                                       throws java.io.IOException
        Truncates the SmbRandomAccessFile by setting its length to the provided value.
        Specified by:
        truncate in interface java.nio.channels.SeekableByteChannel
        Parameters:
        size - New size of the file.
        Returns:
        Current instance of SeekableSMBByteChannel.
        Throws:
        java.io.IOException - If something goes wrong during truncation.
      • isOpen

        public boolean isOpen()
        Determines whether the current SeekableSMBByteChannel is still opened.
        Specified by:
        isOpen in interface java.nio.channels.Channel
        Returns:
        True if SeekableSMBByteChannel and false otherwise.
      • close

        public void close()
                   throws java.io.IOException
        Closes the current SeekableSMBByteChannel. After that, it is not possible to either read from or write to the channel.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.nio.channels.Channel
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException - If something goes wrong while closing the channel.