Answer the question
In order to leave comments, you need to log in
How to get values from HttpsUrlConnection?
Karoch, I'll send a request to YouTube, I get a bunch of lines, how can I get what I need from these lines? Didn't find the answer anywhere, who fumbles?
URL url = new URL(texturl.replace("{id}", args[0]));
HttpsURLConnection connect = (HttpsURLConnection) url.openConnection();
connect.setDoOutput(true);
connect.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connect.getInputStream()));
String decodedString;
while ((decodedString = in.readLine()) != null) {
System.out.println(decodedString);
}
in.close();
{
"kind": "youtube#videoListResponse",
"etag": "q20uri3_U3aqnEUEbGRnZPlxUbA",
"items": [
{
"kind": "youtube#video",
"etag": "ESLK6bJzgoGRSORoWeDkjuuzoQ8",
"id": "vlVQiwYG8eg",
"statistics": {
"viewCount": "1618110",
"likeCount": "38821",
"dislikeCount": "1160",
"favoriteCount": "0",
"commentCount": "1738"
}
}
],
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
}
}
Answer the question
In order to leave comments, you need to log in
In short, you take Retrofit, Gson, and you get a normal api instead of all that.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question