throw 抛出异常的另类利用

示例:

代码1:

private void help_actionPerformed(ActionEvent e)
   {
    try
   { 
     browser.setUrl(helpFile.GetFileUrl(app_c));
     browser.setTitle(sys.getApplictionLabel("MainFrame",app_c,app_c));
   browser.setVisible(true);   
   }
    catch(Exception ae)
  {
   status.addException(ae);
  }
  if (!status.isSuccessful())
         ShowException.showStatus();
    } 

代码2:

public String GetFileUrl(String app_c)
 {
  File file = new File(sys.getVariable("helpServer_url") + GetFolder(app_c) + "/" + GetFileName(app_c));
  if(!file.exists())
   throw new NHException("can not find !");
  else
  return "file://" + file.getAbsoluteFile().toString();
 }

如果打算 当 代码2 有出现异常,就跳出代码1,则此例可以用之。

 

你可能感兴趣的:(c,exception,String,File,url)