Class File

All Implemented Interfaces:
Closeable, AutoCloseable

public class File extends DiskEntry
  • Method Details

    • write

      public long write(byte[] buffer, long fileOffset)
      Write the data in buffer to this file at position fileOffset.
      Parameters:
      buffer - the data to write
      fileOffset - The offset, in bytes, into the file to which the data should be written
      Returns:
      the actual number of bytes that was written to the file
    • write

      public long write(byte[] buffer, long fileOffset, int offset, int length)
      Write the data in buffer to this file at position fileOffset.
      Parameters:
      buffer - the data to write
      fileOffset - The offset, in bytes, into the file to which the data should be written
      offset - the start offset in the data
      length - the number of bytes that are written
      Returns:
      the actual number of bytes that was written to the file
    • write

      public long write(ByteChunkProvider provider)
      Write all available data from the byte chunk provider to this file. The offset in the file to which data is written is determined by ByteChunkProvider.getOffset().
      Parameters:
      provider - the byte chunk provider
      Returns:
      the actual number of bytes that was written to the file
    • write

      public long write(ByteChunkProvider provider, ProgressListener progressListener)
      Write all available data from the byte chunk provider to this file. The offset in the file to which data is written is determined by ByteChunkProvider.getOffset().
      Parameters:
      provider - the byte chunk provider
      progressListener - an optional callback that will be invoked when data has been written to the file
      Returns:
      the actual number of bytes that was written to the file
    • writeAsync

      public Future<Long> writeAsync(byte[] buffer, long fileOffset, int offset, int length)
      Write the data Async in buffer to this file at position fileOffset.
      Parameters:
      buffer - the data to write
      fileOffset - The offset, in bytes, into the file to which the data should be written
      offset - the start offset in the data
      length - the number of bytes that are written
      Returns:
      A Future containing the total number of bytes written to the remote.
    • writeAsync

      public Future<Long> writeAsync(ByteChunkProvider provider)
      Async Write all available data from the byte chunk provider to this file. The offset in the file to which data is written is determined by ByteChunkProvider.getOffset().
      Parameters:
      provider - the byte chunk provider
      Returns:
      A future containing the total number of bytes written to the remote.
    • getOutputStream

      public OutputStream getOutputStream()
    • getOutputStream

      public OutputStream getOutputStream(boolean append)
    • getOutputStream

      public OutputStream getOutputStream(ProgressListener listener)
    • getOutputStream

      public OutputStream getOutputStream(ProgressListener listener, boolean append)
    • read

      public int read(byte[] buffer, long fileOffset)
      Read data from this file starting at position fileOffset into the given buffer.
      Parameters:
      buffer - the buffer to write into
      fileOffset - The offset, in bytes, into the file from which the data should be read
      Returns:
      the actual number of bytes that were read; or -1 if the end of the file was reached
    • read

      public int read(byte[] buffer, long fileOffset, int offset, int length)
      Read data from this file starting at position fileOffset into the given buffer.
      Parameters:
      buffer - the buffer to write into
      fileOffset - The offset, in bytes, into the file from which the data should be read
      offset - the start offset in the buffer at which to write data
      length - the maximum number of bytes to read
      Returns:
      the actual number of bytes that were read; or -1 if the end of the file was reached
    • read

      public void read(OutputStream destStream) throws IOException
      Throws:
      IOException
    • read

      public void read(OutputStream destStream, ProgressListener progressListener) throws IOException
      Throws:
      IOException
    • write

      public long write(ByteBuffer buffer, long fileOffset)
      Write the data in a ByteBuffer to this file at position fileOffset.
      Parameters:
      buffer - the data to write
      fileOffset - The offset, in bytes, into the file to which the data should be written
      Returns:
      the actual number of bytes that was written to the file
    • read

      public long read(ByteBuffer buffer, long fileOffset)
      Read data from this file starting at position fileOffset into the given ByteBuffer.
      Parameters:
      buffer - the ByteBuffer to write into
      fileOffset - The offset, in bytes, into the file from which the data should be read
      Returns:
      the actual number of bytes that were read; or -1 if the end of the file was reached
    • remoteCopyTo

      public void remoteCopyTo(File destination) throws Buffer.BufferException, TransportException
      Performs a remote file copy of this file to the given file.

      This method is equivalent to calling remoteCopyTo(0, destination, 0, sourceFileSize).

      Parameters:
      destination - the destination file
      Throws:
      Buffer.BufferException
      TransportException
    • remoteCopyTo

      public void remoteCopyTo(long offset, File destination, long destinationOffset, long length) throws Buffer.BufferException, TransportException
      Copies the byte range [offset, length] of this file to the range [destinationOffset, length] of the given destination file.
      Parameters:
      destination - the destination file
      Throws:
      Buffer.BufferException
      TransportException
    • setLength

      public void setLength(long endOfFile) throws SMBApiException
      The function for truncate or set file length for a file
      Parameters:
      endOfFile - 64-bit signed integer in bytes, MUST be greater than or equal to 0
      Throws:
      SMBApiException
    • getInputStream

      public InputStream getInputStream()
    • getInputStream

      public InputStream getInputStream(ProgressListener listener)
    • toString

      public String toString()
      Overrides:
      toString in class Object