Page 725 - 3-2
P. 725
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
Log.d(this.getClass().getName(), "3 접근");
BufferedReader br = new BufferedReader(new
InputStreamReader(conn.getInputStream(), "UTF-8"));
Log.d(this.getClass().getName(), "4 접근");
for (; ; ) {
// 웹상에 보여지는 텍스트를 라인단위로 읽어 저장.
Log.d(this.getClass().getName(), "5 접근");
String line = br.readLine();
Log.d(this.getClass().getName(), "6 접근");
if (line == null) break;
// 저장된 텍스트 라인을 jsonHtml 에 붙여넣음
Log.d(this.getClass().getName(), "7 접근");
jsonHtml.append(line + "\n");
Log.d(this.getClass().getName(), " 연결 완료");
}
br.close();
Log.d(this.getClass().getName(), "br close");
}
conn.disconnect();
Log.d(this.getClass().getName(), " 연결 끝");
}
} catch (Exception ex) {
ex.printStackTrace();
Log.d(this.getClass().getName(), " 연결 실패");
}
try {
JSONObject root = new JSONObject(jsonHtml.toString());
JSONArray ja = root.getJSONArray("results");
ja1 = ja.length();
JSONObject jo = ja.getJSONObject(0);
num = jo.getString("num");
money = jo.getString("money");
listItem.add(new ListItem(num, money));
} catch (JSONException e) {
e.printStackTrace();
Log.d(this.getClass().getName(), " 값 저장 실패");
}
}
}
}
------------------------------------------------------
F. ListItem
- 725 -