atualização

This commit is contained in:
Felipe Domingos 2022-02-10 08:58:51 -03:00
parent 61f316f896
commit 020fc49b6b
2 changed files with 40 additions and 0 deletions

Binary file not shown.

40
tps/fonte/ExemploURL.java Normal file
View File

@ -0,0 +1,40 @@
import java.io.*;
import java.net.*;
class ExemploURL {
public static String getHtml(String endereco){
URL url;
InputStream is = null;
BufferedReader br;
String resp = "", line;
try {
url = new URL(endereco);
is = url.openStream(); // throws an IOException
br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
resp += line + "\n";
}
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
try {
is.close();
} catch (IOException ioe) {
// nothing to see here
}
return resp;
}
public static void main(String[] args) {
String endereco, html;
endereco = "http://maratona.crc.pucminas.br/series/Friends.html";
html = getHtml(endereco);
System.out.print(html);
}
}