我有以下代码块,它使用在http://www.jcraft.com/jsch/找到的 JSCH 库
try {
channel.put(f, filename);
} catch (FileNotFoundException e) {
System.out.println("no file.");
}
我知道当 f 指定的文件在本地找不到时 put 方法可以抛出 FileNotFoundException,但是 eclipse 告诉我 catch 块不可访问,并且永远不会抛出该异常。当我更改为:
try {
channel.put(f, filename);
} catch (Exception e) {
System.out.println(e.getMessage());
}
我得到:
java.io.FileNotFoundException: C:\yo\hello2 (The system cannot find the file specified)
有任何想法吗?