List all files in remote server using Jsch

后端 未结 4 373
萌比男神i
萌比男神i 2021-01-14 02:38

I am trying to list all the files/directory from a remote server using JSCH and i can able to get all the information as well..

But my problem is JSCH list all the

4条回答
  •  借酒劲吻你
    2021-01-14 02:50

    try to exec ls command :

    Channel channel=session.openChannel("exec"); 
    ((ChannelExec)channel).setCommand("cd " + SFTPWORKINGDIR + " && ls");
    channel.connect();
    channel.run();
    
    Vector filelist = channel.run();
    for (int i = 0; i < filelist.size(); i++) {
        System.out.println(filelist.get(i).toString());
    }
    

提交回复
热议问题