Type Parameters:
F - the target system file type.
All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
CachingSessionFactory.CachedSession, FtpSession, SftpSession, SmbSession

public interface Session<F> extends Closeable
Common abstraction for a Session with a remote File system.
Since:
2.0
Author:
Josh Long, Mario Gray, Mark Fisher, Oleg Zhurakousky, Gary Russell, Alen Turkovic, Artem Bilan
  • Method Details

    • remove

      boolean remove(String path) throws IOException
      Throws:
      IOException
    • list

      F[] list(String path) throws IOException
      Throws:
      IOException
    • read

      void read(String source, OutputStream outputStream) throws IOException
      Throws:
      IOException
    • write

      void write(InputStream inputStream, String destination) throws IOException
      Throws:
      IOException
    • append

      void append(InputStream inputStream, String destination) throws IOException
      Append to a file.
      Parameters:
      inputStream - the stream.
      destination - the destination.
      Throws:
      IOException - an IO Exception.
      Since:
      4.1
    • mkdir

      boolean mkdir(String directory) throws IOException
      Throws:
      IOException
    • rmdir

      boolean rmdir(String directory) throws IOException
      Remove a remote directory.
      Parameters:
      directory - The directory.
      Returns:
      True if the directory was removed.
      Throws:
      IOException - an IO exception.
      Since:
      4.1
    • rename

      void rename(String pathFrom, String pathTo) throws IOException
      Throws:
      IOException
    • close

      void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • isOpen

      boolean isOpen()
    • exists

      boolean exists(String path) throws IOException
      Check if the remote file or directory exists.
      Parameters:
      path - the remote path.
      Returns:
      true or false if remote path exists or not.
      Throws:
      IOException - an IO exception during remote interaction.
    • listNames

      String[] listNames(String path) throws IOException
      Throws:
      IOException
    • readRaw

      InputStream readRaw(String source) throws IOException
      Retrieve a remote file as a raw InputStream.
      Parameters:
      source - The path of the remote file.
      Returns:
      The raw inputStream.
      Throws:
      IOException - Any IOException.
      Since:
      3.0
    • finalizeRaw

      boolean finalizeRaw() throws IOException
      Invoke after closing the InputStream from readRaw(String). Required by some session providers.
      Returns:
      true if successful.
      Throws:
      IOException - Any IOException.
      Since:
      3.0
    • getClientInstance

      Object getClientInstance()
      Get the underlying client library's client instance for this session. Returns an Object to avoid significant changes to -file, -ftp, -sftp modules, which would be required if we added another generic parameter. Implementations should narrow the return type.
      Returns:
      The client instance.
      Since:
      4.1
    • getHostPort

      String getHostPort()
      Return the host:port pair this session is connected to.
      Returns:
      the host:port pair this session is connected to.
      Since:
      5.2
    • test

      default boolean test()
      Test the session is still alive, e.g. when checking out from a pool. The default implementation simply delegates to isOpen().
      Returns:
      true if the test is successful.
      Since:
      5.1
    • dirty

      default void dirty()
      Mark this session as dirty, indicating that it should not be reused and any delegated sessions should be taken care of before closing.
      Since:
      5.1.2
      See Also: