wamp서버를 이용해서 htdocs에 있는 xml데이터를 읽어오려고 합니다
디버깅을 해보니 IOException으로 넘어가버리더라구요.
다른 학생들것과 비교를 해봤는데도 큰 차이점이 없구요.혹시 제 코드가 잘못된 부분이 있나요?
public void getData(View v)
{
URL url = null; HttpURLConnection urlConnection;
String strUrl = "http://10.0.2.2/wellsites/welldata.xml";
try
{
url = new URL(strUrl);
urlConnection = (HttpURLConnection) url.openConnection();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
readStream(in);
urlConnection.disconnect();
}
catch (MalformedURLException e)
{
toastText("test1");
e.printStackTrace();
TextView tv = (TextView) findViewById(R.id.textView3);
tv.setText(e.getMessage());
}
catch (IOException e)
{
toastText("test2");
e.printStackTrace();
TextView tv = (TextView) findViewById(R.id.textView3);
tv.setText(e.getMessage());
}
finally
{
}
}
private void readStream(InputStream in)
{
try
{
toastText("test3");
BufferedReader r = new BufferedReader(new InputStreamReader(in));
StringBuilder total = new StringBuilder();
String line;
while ((line = r.readLine()) != null)
{
total.append(line);
}
TextView tv = (TextView) findViewById(R.id.textView3);
tv.setText(total.toString());
}
catch (IOException e)
{
toastText("test4");
e.printStackTrace();
TextView tv = (TextView) findViewById(R.id.textView3);
tv.setText(e.getMessage());
}
}