在使用apache.common.net时自定义了一个异常,想在初始化方法时扑捉到异常后都抛出该异常,但是遇到了问题,代码如雪啊
private boolean intconnect(String host, int port) throws TelnetException {
tc = new TelnetClient();
TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler(
"VT100", false, false, true, false);
EchoOptionHandler echoopt = new EchoOptionHandler(true, false, true,
false);
SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true,
true, true);
try {
tc.addOptionHandler(ttopt);
tc.addOptionHandler(echoopt);
tc.addOptionHandler(gaopt);
tc.connect(host, port);
in = tc.getInputStream();
out = new PrintStream(tc.getOutputStream());
return true;
} catch (InvalidTelnetOptionException e) {
System.err.println("Error registering option handlers: "
+ e.getMessage());
01 //throw new TelnetException("Error registering option handlers");
} catch (IOException e) {
e.printStackTrace();
02 throw new TelnetException("Error registering option handlers");
}
03 return false;
}
01、02、03行不能同时存在,必须注释掉一行,不然就有编译错误,请高手指点谜经