Добрый вечер, начал изучать java и хочу отправлять get запрос на vk api и получать ответ в json.
Имеется данный код:
String url = "https://api.vk.com/method/users.get?user_id=*ID*&access_token=*TOKEN*&v=5.80";
URL obj = new URL(url);
HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
Но мне кидает следующую ошибку при компиляции:
error: unreported exception MalformedURLException; must be caught or
declared to be thrown
URL obj = new URL(url);
^
error: unreported exception IOException; must be caught or declared
to be thrown
HttpURLConnection connection = (HttpURLConnection) obj.openConne
ction();
^
error: unreported exception ProtocolException; must be caught or de
clared to be thrown
connection.setRequestMethod("GET");
^
error: unreported exception IOException; must be caught or declared
to be thrown
BufferedReader in = new BufferedReader(new InputStreamReader(con
nection.getInputStream()));
^
error: unreported exception IOException; must be caught or declared
to be thrown
while ((inputLine = in.readLine()) != null) {
^
error: unreported exception IOException; must be caught or declared
to be thrown
in.close();
^
6 errors
Очень буду благодарен.