у меня возникли проблемы с использованием JSCH для извлечения файлов/папок и их заполнения в JTree. В JCH для отображения файлов используйте:
Список векторов = каналSftp.ls(путь);
Но мне нужны эти списки как тип java.io.File. Итак, я могу получить absolutePath и fileName, и я не знаю, как получить тип java.io.File.
Вот мой код, и я пытаюсь работать с локальным каталогом.
public void renderTreeData(String directory, DefaultMutableTreeNode parent, Boolean recursive) {
File [] children = new File(directory).listFiles(); // list all the files in the directory
for (int i = 0; i < children.length; i++) { // loop through each
DefaultMutableTreeNode node = new DefaultMutableTreeNode(children[i].getName());
// only display the node if it isn't a folder, and if this is a recursive call
if (children[i].isDirectory() && recursive) {
parent.add(node); // add as a child node
renderTreeData(children[i].getPath(), node, recursive); // call again for the subdirectory
} else if (!children[i].isDirectory()){ // otherwise, if it isn't a directory
parent.add(node); // add it as a node and do nothing else
}
}
}
Пожалуйста, помогите мне, заранее спасибо :)