我需要捕獲線程運行時發生的線程異常。
我試圖拋出新的異常,但它顯示錯誤,「未報告的異常......必須被捕獲或聲明拋出」.2 如果不可能,那麼爲什麼? 如果你能解釋原因。Catch異常線程外側
這裏是我的代碼
try {
log("Connecting to Module..");
int no = searchdevices.getSelectedIndex();
String Selectaddress = searchdevices.getString(no);
String name = Selectaddress.substring(0, 6);
String add = Selectaddress.substring(Selectaddress.indexOf("$") + 1);
if (no == -1) {
Alert al = new Alert("Warning", "" + no, null, AlertType.WARNING);
al.setTimeout(3000);
display.setCurrent(al);
}
final String fdata2 = "btspp://" + add + ":1;master=false;encrypt=false;authenticate=false";
finalurl = fdata2;
fbtname = name;
// fbtadd = add;
new Thread(new Runnable() {
public void run() {
try {
isConnOpen = true;
stream = (StreamConnection) Connector.open(fdata2);
in = stream.openInputStream();
out = stream.openOutputStream();
url2 = fdata2;
GoTo_Success();
} catch (IOException ex) {
throw new Exception();//in side exception
}
}
}).start();
} catch (Exception e) {
log("Please switch on bluetooth and then try again"); // want to catch here..
}
謝謝。
向我們展示您的代碼,您試圖拋出異常。 – 2011-04-30 05:48:23
我已經把代碼。 – Nirav 2011-04-30 05:53:48