1. 程式人生 > >java-疑問-遠程連接linux服務器找不到文件路徑

java-疑問-遠程連接linux服務器找不到文件路徑

ole ssh npr ktr lec ica trac print use

連接後,遍歷文件夾,打開其中一個文件報找不到文件路徑,不知為何,待解

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(); }

java-疑問-遠程連接linux服務器找不到文件路徑