- 함수 url_get_contents()
1 Java[ | ]
Java
Copy
private static String url_get_contents(String urlstr) {
String content = null;
try {
URL url = new URL(urlstr);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.getResponseCode();
InputStream stream = connection.getErrorStream();
if (stream == null) stream = connection.getInputStream();
Scanner scanner = new Scanner(stream);
scanner.useDelimiter("\\Z");
content = scanner.next();
scanner.close();
}
catch (MalformedURLException e) { e.printStackTrace(); }
catch (IOException e) { e.printStackTrace(); }
return content;
}
2 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.