1
I would like to do as I get html code from a site using android studio. This is the code I did, but it does not returns anything.
private static String pegarURL(String a) {
StringBuilder b = new StringBuilder();
try {
URL url = new URL(a);
URLConnection urlConnection = url.openConnection();
BufferedReader bufferedReader =
new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null) {
b.append(line + "\n");
}
bufferedReader.close();
} catch(Exception e) {
e.printStackTrace();
}
return b.toString();
}
String h = pegarURL("https://www.google.com/");
Thanks, I used several forms, but none worked. This one served me well. Thanks!
– Coelho
You are welcome! I had already searched several, I found some that worked, but I had to use many more codes.
– Vinicius Petrachin