Ich bin neu im SFTP-Protokoll. Ich muss alle Dateien und Ordner von einem Server mit SFTP-Protokoll auflisten. I umgesetzt diese mit Hilfe der JSch Bibliothek:Wie kann ich alle Dateien von einem SFTP-Server mit Java auflisten?
public ArrayList<JSONObject> listFiles(String deviceName, String location) throws Exception
{
this.sftpLogin();
Vector fileListVector;
if (Strings.isNullOrEmpty(location))
{
fileListVector = channelSftp.ls("/");
} else
{
fileListVector = channelSftp.ls("/"+location);
}
ArrayList<JSONObject> fileList = new ArrayList<>();
for (Object aFileListVector : fileListVector)
{
ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) aFileListVector;
if (entry.getFilename().equalsIgnoreCase(".") || entry.getFilename().equalsIgnoreCase(".."))
{
continue;
}
SftpATTRS attrs = entry.getAttrs();
fileList.add(ImportProtocolUtils.getFileJSONObject(attrs.isDir(), location, entry.getFilename()));
}
return fileList;
}
ich versuchte 'Shell' und 'exec' -Kanal dies das Protokoll. Aber der Befehl 'ls' funktioniert nicht.
Welches ist die beste Bibliothek dafür in Java?
Vielen Dank im Voraus.