2017년 6월 12일 월요일

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

1. url에서 읽어온 InputStream을 String 변환 공통 함수

2. 인터넷에서 대충 줒은거 개조했음.


public static void printByInputStream(InputStream is, String tgtMode) {
  byte[] buf = new byte[2048];
  StringBuffer sb = new StringBuffer();
  int len = -1;
  try {
   while ((len = is.read(buf, 0, buf.length)) != -1) {
    sb.append(new String(buf, 0, len));
   }   
   
   System.out.println(sb.toString());
   
   if(tgtMode.equals("weather")){
    parseWeather(sb.toString());
   }else{
    parseAir(sb.toString());
   }
   
  } catch (IOException e) {
   e.printStackTrace();
  }  
 }

댓글 없음:

댓글 쓰기

[DOS] ULTIMA 2 클리어

  몰아쓰는 거라.. 포스팅을 또 함.. ​ 울티마를 하려면.. 일단 메뉴얼부터 정독을 하고 뭘해야 할 지를 정한다음 게임을 해야 한다.. ​ 2편 메뉴얼을 보니.. 형편없는 쓰레기게임이구나.. 라는 생각만 든다.. ​ 낭만의 시대적 게임이라.. 정말...