Boa noite galera, estou com um problema, nesse método eu leio um arquivo txt
ex:
Residencial;AV. WALDEMAR BASTOS BULHER - JD. ALV. II;FABIO;150;63;2;4;
Vago;RUA BENTO DO CARMO - JD. MARISTELA;ALISSON;351,6;;;;
Vago;RUA SEBASTIAO CAVALHEIRO - JD. MARISTELA;MAURICIO;150;;;;
mais como vcs podem ver entre alguns ; n tem nenhum valor, ai da erro no meu codigo
private static void lerArquivo() throws Exception {
try {
FileReader leitor = new FileReader("dados_prefeitura.txt");
BufferedReader br = new BufferedReader(leitor);
String linha = br.readLine();
String conteudo = "";
while (linha != null) {
conteudo += linha + "\n";
linha = br.readLine();
}
br.close();
String[] ler = conteudo.split("\n");
for (int i = 1; i < ler.length; i++) {
String string = ler[i];
String[] dados = string.split(";");
String endereco = dados[1];
String proprietario = dados[2];
Double valorMetro = Math.random() * 1000000;
String str = dados[3];
Double area = Double.valueOf(str.replace(",", "."));
if (dados[0].equalsIgnoreCase("VAGO")) {
Negocio.addTerrenoVazio(endereco, proprietario, area, valorMetro);
}
String str1 = dados[4];
Double areaEdificada = Double.valueOf(str1.replace(",", "."));
Integer pavimentos = Integer.valueOf(dados[5]);
if (dados[0].equalsIgnoreCase("RESIDENCIAL")) {
Integer nMoradores = Integer.valueOf(dados[6]);
Negocio.addImovelResidencial(endereco, proprietario, area, valorMetro, areaEdificada, pavimentos, nMoradores);
}
if (dados[0].equalsIgnoreCase("COMERCIAL")) {
String tipo = dados[7];
Negocio.addImovelComercial(endereco, proprietario, area, valorMetro, areaEdificada, pavimentos, tipo);
}
}
} catch (Exception e) {
System.out.println("Arquivo não encontrado " + e.getMessage());
System.exit(0);
}
}
