Reputation: 53
I want to send a file from phone to computer,but it gives an error(No such File) but i didn't solve this problem.What is the problem?I'm using 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();
Upvotes: 0
Views: 136
Reputation: 53
Ok,i solved this problem,Here is the Code:
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);
}
Upvotes: 1