Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File arquivoLeitura = new File(getArquivo());
- LineNumberReader linhaLeitura = new LineNumberReader(new FileReader(arquivoLeitura));
- linhaLeitura.skip(arquivoLeitura.length());
- int qtdLinha = linhaLeitura.getLineNumber() + 1;
- BufferedReader leitor = new BufferedReader(new InputStreamReader(new FileInputStream(getArquivo())));
- String linha = null;
- int indiciosComErros = 0;
- for (int i = 1; i <= qtdLinha; i++ ) {
- linha = leitor.readLine();
- String[] dadosCSV = linha.split(VIRGULA);
- System.out.println(Arrays.toString(dadosCSV));
- System.out.println( dadosCSV[0]);
- System.out.println( dadosCSV[1]);
- System.out.println( dadosCSV[2]);
- System.out.println( dadosCSV[3]);
- System.out.println( dadosCSV[4]);
- System.out.println(dadosCSV[5]);
- System.out.println("--------------------------");
- if (pessoaJuridicaPublicaService.getPorId(Long.parseLong(dadosCSV[1])) == null) {
- indiciosComErros = indiciosComErros + 1;
- }
- }
- leitor.close();
- class ErroCSV {
- private int linhaErro;
- private String[] dados;
- public ErroCSV(int linhaErro, String[] dados) {
- this.linhaErro = linhaErro;
- this.dados = dados;
- }
- public int getLinhaErro() {
- return linhaErro;
- }
- public String[] getDados() {
- return dados;
- }
- }
- List<ErroCSV> erroCSVList = new Arraylist<>();
- for (int i = 1; i <= qtdLinha; i++ ) {
- linha = leitor.readLine();
- String[] dadosCSV = linha.split(VIRGULA);
- System.out.println(Arrays.toString(dadosCSV));
- System.out.println( dadosCSV[0]);
- System.out.println( dadosCSV[1]);
- System.out.println( dadosCSV[2]);
- System.out.println( dadosCSV[3]);
- System.out.println( dadosCSV[4]);
- System.out.println(dadosCSV[5]);
- System.out.println("--------------------------");
- if (pessoaJuridicaPublicaService.getPorId(Long.parseLong(dadosCSV[1])) == null) {
- erroCSVList.add(new ErroCSV(i, dadosCSV));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement