我试图从 FTP 环境中获取文件的最后修改日期。结果不符合预期。
通过使用ftpClient.getModificationTime("File path")我得到null。
通过使用FTPFile.getTimestamp().getTime()我得到了错误的最后修改(即真正的最后修改是今天,我得到的是Wed Feb 18 02:55:22 EST 2004)。
如何获得正确的最后修改时间?
提前致谢。
使用的框架:Spring
使用的ORM:Hibernate
我有两节课
class BatchExceptionDetails{
...
private Set<BatchExceptionComments> batchExceptionComments;
}
class BatchExceptionComments implements Comparable<BatchExceptionComments>{
...
@Override
public int compareTo(BatchExceptionComments o) {
// TODO Auto-generated method stub
return this.getAddedOn().compareTo(o.getAddedOn());
}
}
Run Code Online (Sandbox Code Playgroud)
它们使用一对多映射进行映射.
BatchExceptionDetails中有一组BatchExceptionComments.
我想在Date的基础上对集合进行排序.BatchExcpetionComment具有java.util.Date类型的属性,即addedOn.我希望最新评论成为集合的第一个元素.
我收到的集合没有排序.请你指导我出错的地方.
提前致谢
我想使用 JSch 在远程位置显示目录的完整层次结构。该位置有多个文件夹,一个文件夹可能有也可能没有文件。
我写的代码(参考SFTP Read all files in directory):
sftpChannel.cd(remotePath);
Vector<String> files = sftpChannel.ls("*");
List<String> ret=new ArrayList<>();
for (int i = 0; i < files.size(); i++)
{
Object obj = files.elementAt(i);
if (obj instanceof com.jcraft.jsch.ChannelSftp.LsEntry)
{
LsEntry entry = (LsEntry) obj;
if (true && !entry.getAttrs().isDir())
{
ret.add(entry.getFilename()+"file");
}
if (true && entry.getAttrs().isDir())
{
if (!entry.getFilename().equals(".") && !entry.getFilename().equals(".."))
{
ret.add(entry.getFilename()+"folder");
}
}
}
}
System.out.println(ret);
Run Code Online (Sandbox Code Playgroud)
此代码仅显示顶级文件夹名称,不会读取这些文件夹中的文件。
我正在使用 jsch-0.1.54。
谢谢