2017년 6월 12일 월요일

3. JAVA로 날씨정보, 대기정보 호출...

1. 대기정보값 받기..


public static void getAir(String lat, String lon){
  httpclient = HttpClients.createDefault();
  String callUrl = setLocation(lat, lon, "air");
  try {
   HttpGet httpGet = new HttpGet(callUrl);     //대기정보 url 호출...
   httpGet.addHeader("appKey", appKeyId);
   System.out.println(httpGet.getURI());
   System.out.println("[Executing request]: " + httpGet.getRequestLine());

   HttpResponse response = httpclient.execute(httpGet);

   //System.out.println(response.toString());
   InputStream in2;
   in2 = response.getEntity().getContent();
   printByInputStream(in2 , "air");
   in2.close();
  } catch (ClientProtocolException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } finally {
   
  }
 }

댓글 없음:

댓글 쓰기

[낯선] 2025.10.11 인천 노크 공연

  Live at @인천노크 on 2025.10.11 Set List 1. 디어클라우드 - 얼음요새 Covered by 낯선 2. 낯선 - Misty Dive 3. 솔루션스 - 청춘 Covered by 낯선 4. 낯선 - Not Your Fault...