import java.net.MalformedURLException;
import java.io.*;
import java.net.URL;
import java.io.BufferedReader;
class html {
public static void main(String[] args) {
String end = "";
String nome = "";
do {
nome = MyIO.readLine();
end = MyIO.readLine();
if(fimteste(nome) == false) {
processaHtml(end, nome);
}
}while(fimteste(nome) == false);
}
public static void processaHtml (String endereco, String nome ) {
String linha;
BufferedReader br;
int valores [] = new int [26];
for (int i = 0; i < 26; i++ ) {
valores [i] = 0;
}
try {
URL url = new URL (endereco);
InputStream is = url.openStream();
br = new BufferedReader(new InputStreamReader(is)) ;
while ((linha = br.readLine()) != null) {
processaLinha(linha, valores) ;
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
MyIO.print("a (" + valores[0] + " )");
MyIO.print("e (" + valores[1] + " )");
MyIO.print("i (" + valores[2] + " )");
MyIO.print("o (" + valores[3] + " )");
MyIO.print("u (" + valores[4] + " )");
MyIO.print("á (" + valores[5] + " )");
MyIO.print("é (" + valores[6] + " )");
MyIO.print("í (" + valores[7] + " )");
MyIO.print("ó (" + valores[8] + " )");
MyIO.print("ú (" + valores[9] + " )");
MyIO.print("à (" + valores[10] + " )");
MyIO.print("è (" + valores[11] + " )");
MyIO.print("ì (" + valores[12] + " )");
MyIO.print("ò (" + valores[13] + " )");
MyIO.print("ù (" + valores[14] + " )");
MyIO.print("ã (" + valores[15] + " )");
MyIO.print("õ (" + valores[16] + " )");
MyIO.print("â (" + valores[17] + " )");
MyIO.print("ê (" + valores[18] + " )");
MyIO.print("î (" + valores[19] + " )");
MyIO.print("ô (" + valores[20] + " )");
MyIO.print("û (" + valores[21] + " )");
MyIO.print("consoante (" + valores[22] + " )");
MyIO.print("<br> (" + valores[23] + " )");
MyIO.print("<table> (" + valores[24] + " )");
MyIO.print(nome);
}
//colocar para printar cada um com a +(valores[0]) felipe@pucminas.com.br
public static void processaLinha (String linha, int [] valores) {
for (int i = 0; i < linha.length(); i++ ) {
int pos = linha.charAt(i);
switch (pos) {
case 'a' :
valores[0]++;
break;
case 'e' :
valores[1]++;
break;
case 'i' :
valores[2]++;
break;
case 'o' :
valores[3]++;
break;
case 'u' :
valores[4]++;
break;
case 'á' :
valores[5]++;
break;
case 'é' :
valores[6]++;
break;
case 'í' :
valores[7]++;
break;
case 'ó' :
valores[8]++;
break;
case 'ú' :
valores[9]++;
break;
case 'à':
valores[10]++;
break;
case 'è' :
valores[11]++;
break;
case 'ì' :
valores[12]++;
break;
case 'ò' :
valores[13]++;
break;
case 'ù' :
valores[14]++;
break;
case 'ã' :
valores[15]++;
break;
case 'õ' :
valores[16]++;
break;
case 'â' :
valores[17]++;
break;
case 'ê' :
valores[18]++;
break;
case 'î' :
valores[19]++;
break;
case 'ô' :
valores[29]++;
break;
case 'û' :
valores[21]++;
break;
case 'b' :
valores[22]++;
break;
case 'c' :
valores[22]++;
break;
case 'd' :
valores[22]++;
break;
case 'f' :
valores[22]++;
break;
case 'g' :
valores[22]++;
break;
case 'h' :
valores[22]++;
break;
case 'j' :
valores[22]++;
break;
case 'k' :
valores[22]++;
break;
case 'l' :
valores[22]++;
break;
case 'm' :
valores[22]++;
break;
case 'n' :
valores[22]++;
break;
case 'p' :
valores[22]++;
break;
case 'q' :
valores[22]++;
break;
case 'r' :
valores[22]++;
break;
case 's' :
valores[22]++;
break;
case 't' :
valores[22]++;
break;
case 'v' :
valores[22]++;
break;
case 'w' :
valores[22]++;
break;
case 'x' :
valores[22]++;
break;
case 'y' :
valores[22]++;
break;
case 'z' :
valores[22]++;
break;
case '<' :
if(linha.charAt(i+1) == 'b') {
if(linha.charAt(i+2) == 'r') {
if(linha.charAt(i+3) == '>') {
valores[23]++;
break;
}
}
}else if(linha.charAt(i+1) == 't') {
if(linha.charAt(i+2) == 'a' ) {
if(linha.charAt(i+3) == 'b') {
if(linha.charAt(i+4) == 'l') {
if(linha.charAt(i+5) == '>') {
valores[24]++;
break;
}
}
}
}
}
default : break;
}
}
}
static boolean fimteste (String a) {
String defo = "FIM";
boolean teste = false;
int cont = 0;
if(a.length() == defo.length()) {
for(int i=0; i < a.length(); i++) {
if(a.charAt(i)==defo.charAt(i)) {
cont++;
}
}
}
if(cont == 3) teste = true;
return teste;
}
}Texto pré-formatado
Preciso de ajuda para entender os erros desse programa no metodo processaHTML,
nao conheço muito dos metodos BufferedReader, nem criação de URL no java.