我想从手机向计算机发送文件,但是它出错(没有这样的文件)但我没有解决这个问题。问题是什么?我正在使用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();
答案 0 :(得分: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);
}