2012-10-15 18 views
0

我想從手機發送文件到電腦,但它給出了一個錯誤(沒有這樣的文件),但我沒有解決這個問題?problem.What的問題我使用SFTP server.Code:我想從手機發送(上傳)文件到電腦,但它給出了錯誤

ChannelSftp sftpChannel = (ChannelSftp) channel; 
       try { 

        sftpChannel.cd("/sdcard/download"); 
        String inputFileName =Environment.getExternalStorageDirectory().getAbsolutePath()+"a.txt"; 

        sftpChannel.put(inputFileName, "/home/john/desktop"); 

       } catch (SftpException e) { 
        writeToSDFile("sftp---exception"+e); 
       } 

       sftpChannel.exit(); 

回答

1

好吧,我解決了這個問題,這裏是代碼:

ChannelSftp sftpChannel = (ChannelSftp) channel; 
       writeToSDFile("9"); 
       try { 

        sftpChannel.cd("/home/john/Desktop"); 
         String inputFileName =Environment.getExternalStorageDirectory().getAbsolutePath()+"/download/myData.txt"; 
         File f = new File(inputFileName); 
         sftpChannel.put(inputFileName, "/home/john/Desktop/myData.txt"); 

       } catch (SftpException e) { 
        writeToSDFile("sftp---exception"+e); 
       } 
相關問題