Class SmbSession
java.lang.Object
org.springframework.integration.smb.session.SmbSession
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Session<jcifs.smb.SmbFile>
Implementation of the 
Session interface for Server Message Block (SMB)
 also known as Common Internet File System (CIFS). The Samba project set out to
 create non-Windows implementations of SMB. Often Samba is thus used synonymously to SMB.
 SMB is an application-layer network protocol that manages shared access to files, printers and other networked resources.
See Server Message Block for more details.
- Since:
- 6.0
- Author:
- Markus Spann, Mark Fisher, Oleg Zhurakousky, Artem Bilan, Prafull Kumar Soni, Gregory Bragg, Adam Jones, Paolo Fosser
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidappend(InputStream inputStream, String destination) Append to a file.voidclose()jcifs.smb.SmbFilecreateSmbDirectoryObject(String _path) Create an SMB file object pointing to a remote directory.jcifs.smb.SmbFilecreateSmbFileObject(String _path) Create an SMB file object pointing to a remote file.booleanCheck whether the remote resource exists.booleanInvoke after closing the InputStream fromSession.readRaw(String).Get the underlying client library's client instance for this session.Return the host:port pair this session is connected to.booleanisDirectory(String _path) Check whether the remote resource is a directory.booleanCheck whether the remote resource is a file.booleanisOpen()Check whether this SMB session is open and ready for work by attempting to list remote files and checking for error conditions.jcifs.smb.SmbFile[]Return the content of the specified SMB resource as an array of SmbFile objects.String[]Return the contents of the specified SMB resource as an array of SmbFile filenames.booleanCreate the specified remote path if not yet exists.voidread(String _path, OutputStream _outputStream) Read the remote resource specified by path and copies its contents to the specifiedOutputStream.Retrieve a remote file as a rawInputStream.booleanDelete the file or directory at the specified path.voidbooleanRemove a remote directory.jcifs.smb.SmbFileConvenience method to write a byte array to a remote location.jcifs.smb.SmbFileConvenience method to write a local file object to a remote location.voidwrite(InputStream _inputStream, String _path) Write contents of the specifiedInputStreamto the remote resource specified by path.
- 
Constructor Details
- 
Method Details- 
removeDelete the file or directory at the specified path.- Specified by:
- removein interface- Session<jcifs.smb.SmbFile>
- Parameters:
- _path- path to a remote file or directory
- Returns:
- true if delete successful, false if resource is non-existent
- Throws:
- IOException- on error conditions returned by a CIFS server
 
- 
listReturn the content of the specified SMB resource as an array of SmbFile objects. In case the remote resource does not exist, an empty array is returned.- Specified by:
- listin interface- Session<jcifs.smb.SmbFile>
- Parameters:
- path- path to a remote directory or remote file path
- Returns:
- array of SmbFile objects
- Throws:
- IOException- on error conditions returned by a CIFS server.
 
- 
listNamesReturn the contents of the specified SMB resource as an array of SmbFile filenames. In case the remote resource does not exist, an empty array is returned.- Specified by:
- listNamesin interface- Session<jcifs.smb.SmbFile>
- Parameters:
- _path- path to a remote directory
- Returns:
- array of SmbFile filenames
- Throws:
- IOException- on error conditions returned by a CIFS server or if the remote resource is not a directory.
 
- 
readRead the remote resource specified by path and copies its contents to the specifiedOutputStream.- Specified by:
- readin interface- Session<jcifs.smb.SmbFile>
- Parameters:
- _path- path to a remote file
- _outputStream- output stream
- Throws:
- IOException- on error conditions returned by a CIFS server or if the remote resource is not a file.
 
- 
writeWrite contents of the specifiedInputStreamto the remote resource specified by path. Remote directories are created implicitly as required.- Specified by:
- writein interface- Session<jcifs.smb.SmbFile>
- Parameters:
- _inputStream- input stream
- _path- remote path (of a file) to write to
- Throws:
- IOException- on error conditions returned by a CIFS server
 
- 
writeConvenience method to write a local file object to a remote location.- Parameters:
- _file- the local file
- _path- the remote path to write to
- Returns:
- the SmbFilefor remote file
- Throws:
- IOException- the IO exception
 
- 
writeConvenience method to write a byte array to a remote location.- Parameters:
- _contents- the- byte[]to write
- _path- the remote file to write to
- Returns:
- the SmbFilefor remote file
- Throws:
- IOException- the IO exception
 
- 
mkdirCreate the specified remote path if not yet exists. If the specified resource is a file rather than a path, creates all directories leading to that file.- Specified by:
- mkdirin interface- Session<jcifs.smb.SmbFile>
- Parameters:
- _path- remote path to create
- Returns:
- always true (error states are express by exceptions)
- Throws:
- IOException- on error conditions returned by a CIFS server
 
- 
existsCheck whether the remote resource exists.- Specified by:
- existsin interface- Session<jcifs.smb.SmbFile>
- Parameters:
- _path- remote path
- Returns:
- true if exists, false otherwise
- Throws:
- IOException- on error conditions returned by a CIFS server
 
- 
isFileCheck whether the remote resource is a file.- Parameters:
- _path- remote path
- Returns:
- true if resource is a file, false otherwise
- Throws:
- IOException- on error conditions returned by a CIFS server
 
- 
isDirectoryCheck whether the remote resource is a directory.- Parameters:
- _path- remote path
- Returns:
- true if resource is a directory, false otherwise
- Throws:
- IOException- on error conditions returned by a CIFS server
 
- 
rename- Specified by:
- renamein interface- Session<jcifs.smb.SmbFile>
- Throws:
- IOException
 
- 
appendDescription copied from interface:SessionAppend to a file.- Specified by:
- appendin interface- Session<jcifs.smb.SmbFile>
- Parameters:
- inputStream- the stream.
- destination- the destination.
- Throws:
- IOException- an IO Exception.
 
- 
rmdirDescription copied from interface:SessionRemove a remote directory.- Specified by:
- rmdirin interface- Session<jcifs.smb.SmbFile>
- Parameters:
- directory- The directory.
- Returns:
- True if the directory was removed.
- Throws:
- IOException- an IO exception.
 
- 
readRawDescription copied from interface:SessionRetrieve a remote file as a rawInputStream.- Specified by:
- readRawin interface- Session<jcifs.smb.SmbFile>
- Parameters:
- source- The path of the remote file.
- Returns:
- The raw inputStream.
- Throws:
- IOException- Any IOException.
 
- 
finalizeRawpublic boolean finalizeRaw()Description copied from interface:SessionInvoke after closing the InputStream fromSession.readRaw(String). Required by some session providers.- Specified by:
- finalizeRawin interface- Session<jcifs.smb.SmbFile>
- Returns:
- true if successful.
 
- 
getClientInstanceDescription copied from interface:SessionGet the underlying client library's client instance for this session. Returns anObjectto avoid significant changes to -file, -ftp, -sftp modules, which would be required if we added another generic parameter. Implementations should narrow the return type.- Specified by:
- getClientInstancein interface- Session<jcifs.smb.SmbFile>
- Returns:
- The client instance.
 
- 
close
- 
isOpen
- 
createSmbFileObjectCreate an SMB file object pointing to a remote file.- Parameters:
- _path- the remote file path
- Returns:
- the SmbFilefor remote path
- Throws:
- IOException- the IO exception
 
- 
createSmbDirectoryObjectCreate an SMB file object pointing to a remote directory.- Parameters:
- _path- the remote directory path
- Returns:
- the SmbFilefor remote path
- Throws:
- IOException- the IO exception
 
- 
getHostPortDescription copied from interface:SessionReturn the host:port pair this session is connected to.- Specified by:
- getHostPortin interface- Session<jcifs.smb.SmbFile>
- Returns:
- the host:port pair this session is connected to.
 
 
-