2014-11-05 2 views

답변

0
BufferedReader in = null; 
try { 
    String urlStr = "https://blockchain.info/de/q/24hrprice"; 
    URL url = new URL(urlStr); 
    URLConnection con = url.openConnection(); 
    in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8")); 
    String input; 
    while ((input = in.readLine()) != null) { 
    System.out.println(input); //you can parse input as Integer or Double now 
    } 

} catch (MalformedURLException ex) { 
    System.err.println(ex); 
} catch (IOException ex) { 
    System.err.println(ex); 
} finally { 
    try { 
    in.close(); 
    } catch (Exception ex) { 
    System.err.println(ex); 
    } 
} 
+0

빠른 응답을 보내 주셔서 감사합니다! 귀하의 코드를 사용하려고하면 이러한 오류가 발생합니다 : 새 URL (urlStr) 오류 : java.net.malformedurlexception url.openConnection, con.getInputStream, in.readLine 및 in.close 오류 : java.io. IOException 내가 뭘 잘못하고 있니? – user3254327

+0

잘 모르겠습니다 ... 그것은 저에게 효과적입니다. 업데이트 된 답변을 복사 했습니까? 방금 urlStr을 변경하여 첫 번째 버전에서하지 않은 "https : //"를 포함 시켰습니다. – vefthym

+0

기다려 ... try-catch 블록에 넣었 니? – vefthym

관련 문제