java - jvm throwing NoSuchElementException when using Scanner -


i'm facing problem don't understand. designed program read info files , generate reports it.

at first time, open files need:

clientesarq = new file(args[1]); fornecedoresarq = new file(args[3]); produtosarq = new file(args[5]); 

then use java.util.scanner loop through them:

leitor = new scanner(clientesarq);     leitor.nextline();      /* leitura e armazenamento dos clientes em mapa */     while(leitor.hasnextline()) {         cliente c = pd.novocliente(leitor);         clientes.addcliente(c);     }      leitor = new scanner(fornecedoresarq);     leitor.nextline();      /* leitura e arazenaento dos fornecedores em mapa */     while(leitor.hasnextline()) {         fornecedor f = pd.novofornecedor(leitor);         fornecedores.addfornecedor(f);     } 

when program reaches part of code, jvm throws me nosuchelementexception.

leitor = new scanner(produtosarq); leitor.nextline(); /* exception here */  /* leitura e armazenamento dos produtos em mapa */ while(leitor.hasnextline()) {     produto p = pd.novoproduto(leitor);     produtos.addproduto(p); } 

i want know why hell getting excpetion, can see, code same other ones. any?

you can needed files here: https://www.dropbox.com/sh/c48roudfwuj7qzu/aaamn_ofgxjfhejvjyz7picpa

use utf-8 character set read file able represent every character in unicode format.

here convert bytes file characters using specified charset(here utf-8) , make readable scanner guess.

scanner input = new scanner(new file("filename"),"utf-8"); 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -