I am using jSch for SFTP in my Java project. I want to get all files attributes in a directory. But there are two methods to retrieve the file attributes of a file or directory.
1. public SftpATTRS stat(String path)
2. public SftpATTRS lstat(String path)
What is the difference b/w these two methods? Please tell me there uses???
public class ChannelSftp extends Channel. A Channel connected to an sftp server (as a subsystem of the ssh server). This class supports the client side of the sftp protocol, version 3, and implements an interface similar to the usual sftp command line client.
Represents a directory entry, representing a remote file or directory. A vector of objects of this inner class is returned by ChannelSftp.ls(java. lang.
JSch is a pure Java implementation of SSH2. JSch allows you to connect to an sshd server and use port forwarding, X11 forwarding, file transfer, etc., and you can integrate its functionality into your own Java programs. JSch is licensed under BSD style license.
The lstat method gives you the stats of the link itself. Think of it like 'link stat'.
The stat method gives you the stats of the target file itself. (It follows the symbolic link).
Example, you have a symbolic link 'myhome' which is actually a shortcut to /u02/home/alamba.
With stat, you will get attributes of the target of the link, the '/u02/home/alamba' folder. With lstat you will get the attributes of the 'myhome' link instead.
ChannelSftp documentation.
Symbolic Link Explanation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With