안녕하세요.
Google에서 제공하는 안드로이드 강의를 보며 실습중이빈다.
이번에 Http 네트워크를 실습하는중 질문이 있어 글 남깁니다.
아래 코드와 같이 Connection을 선언하구 connect() 메소드로 연결하는 과정에서 에러가 나옵니다.
에러메세지가 확인이 안되어 디버깅 모드로 확인을 해봤는데 next step에서 다음 코드로 넘어가지 않고 바로
final 로 건너 뛰어 버리는데 비슷한 경험 가지고 있으신분 계신지요?
도움 부탁드리겠습니다!!
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
// Will contain the raw JSON response as a string.
String forecastJsonStr = null;
try {
// Construct the URL for the OpenWeatherMap query
// Possible parameters are avaiable at OWM's forecast API page, at
// http://openweathermap.org/API#forecast
URL url = new URL("http://api.openweathermap.org/data/2.5/forecast/daily?q=94043&mode=json&units=metric&cnt=7");
// Create the request to OpenWeatherMap, and open the connection
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();
// Read the input stream into a String
InputStream inputStream = urlConnection.getInputStream();