我在Android開發中總是noob。我仍在學習,而且我正在開發我的應用開發的第一步。Android:未處理的異常類型IOException錯誤
我有這個代碼工作,它運行良好或正常的Java,現在我試圖實現Android操作系統。
在我的代碼裏,它表示TEST.openStream()
我得到了Unhandled exception type IOException
錯誤。
package com.zv.android;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import android.app.Activity;
import android.os.Bundle;
public class ZipActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
URL TEST = new URL("http://www.google.com/");
BufferedReader in = new BufferedReader(new InputStreamReader(TEST.openStream()));
String inputLine;
int line=0;
while ((inputLine = in.readLine()) != null){
line++;
//System.out.println(line + "\t" + inputLine);
}
// in.close();
} catch(MalformedURLException e) {
//Do something with the exception.
}
}
}
你能解釋一下爲什麼我們也會發生IOException嗎? – Mowgli
@Mowgli:查看更新。 – kosa