我想把一个正常类svm_predict转化为applet,转换后的代码如下(方法的具体内容略):class svm_predict extends Applet implements ActionListener
{
TextArea ta=new TextArea(50,100);
Button bn=new Button("ok");
public void init()
{
add(ta);
add(bn);
bn.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String argv[]={"test","svm.model","output"};
main(argv);
} private static void predict(BufferedReader input, DataOutputStream output, svm_model model, int predict_probability) throws IOException
{
...
} public static void main(String argv[]) throws IOException
{
...
}
}在编译时出现“未报告的异常 java.io.IOException;必须对其进行捕捉或声明以便抛出main(argv)”错误,请问这是怎么回事?怎么做能消除这个错误?
我对异常处理一窍不通,还请您用通俗一点的话解释一下。谢谢!
{
TextArea ta=new TextArea(50,100);
Button bn=new Button("ok");
public void init()
{
add(ta);
add(bn);
bn.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String argv[]={"test","svm.model","output"};
main(argv);
} private static void predict(BufferedReader input, DataOutputStream output, svm_model model, int predict_probability) throws IOException
{
...
} public static void main(String argv[]) throws IOException
{
...
}
}在编译时出现“未报告的异常 java.io.IOException;必须对其进行捕捉或声明以便抛出main(argv)”错误,请问这是怎么回事?怎么做能消除这个错误?
我对异常处理一窍不通,还请您用通俗一点的话解释一下。谢谢!
{
String argv[]={"test","svm.model","output"};
try {
main(argv);
} catch(Exception ex) {
}
}这样就可以了main方法抛出异常 你调用这个方法 肯定也要处理啊
class svm_predict extends Applet implements ActionListener throws Exception
^