zoukankan      html  css  js  c++  java
  • java-疑问-远程连接linux服务器找不到文件路径

    连接后,遍历文件夹,打开其中一个文件报找不到文件路径,不知为何,待解

    SshClient client=new SshClient();
            try{
                ConsoleKnownHostsKeyVerification console = new ConsoleKnownHostsKeyVerification();  
                client.connect("47.110.70.236",22,console);
                //设置用户名和密码
                PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
                pwd.setUsername("transnftp");
                pwd.setPassword("tqhy@2019");
                int result=client.authenticate(pwd);
                
         
                
                if(result==AuthenticationProtocolState.COMPLETE){//如果连接完成
                    //源文件地址OriginPath
                    String OriginPath="/upload";
                    List<SftpFile> list = client.openSftpClient().ls(OriginPath);
                    
                    int filecount=0;
                    for(SftpFile f:list) {        
                        //三个跨境电商
                        String eCommercePath=f.getAbsolutePath();
                        List<SftpFile> eCommercelist = client.openSftpClient().ls(eCommercePath);
                        
                        for(SftpFile ff:eCommercelist) {
                            //取json结尾文件
                            //0bd4f4c81cc6a16e9a746f756ba52c9f.json
                            if(ff.getFilename().endsWith(".json")) {
                                
                                SessionChannelClient session = client.openSessionChannel();
                                if(session.startShell()) {
                                    BufferedReader in = new BufferedReader(new InputStreamReader(session.getInputStream()));
                                    System.out.println("名称长度:"+ff.getFilename());
                                    System.out.println("地址:"+ff.getAbsolutePath());
                                    System.out.println(in.readLine());
                                    
                                }
                                
                                filecount++;
                                break;
                                
                            }
                            
                        }
                    }
                    System.out.println("文件数为:"+filecount);
                    
               }
            }catch(IOException e){
                e.printStackTrace();
            }
  • 相关阅读:
    信息检索重点句子分析部分
    信息检索重点关键字
    信息检索问答部分
    信息检索重点句子分析部分
    信息检索重点句子分析部分
    信息检索重点句子分析部分
    信息检索问答部分
    信息检索问答部分
    信息检索问答部分
    2007年中国羽毛球大师赛直播时间表
  • 原文地址:https://www.cnblogs.com/lely/p/10250488.html
Copyright © 2011-2022 走看看