문제

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???

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top