Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. File arquivoLeitura = new File(getArquivo());
  2. LineNumberReader linhaLeitura = new LineNumberReader(new FileReader(arquivoLeitura));
  3. linhaLeitura.skip(arquivoLeitura.length());
  4. int qtdLinha = linhaLeitura.getLineNumber() + 1;
  5.  
  6.  
  7. BufferedReader leitor = new BufferedReader(new InputStreamReader(new FileInputStream(getArquivo())));
  8.  
  9. String linha = null;
  10.  
  11. int indiciosComErros = 0;
  12.  
  13. for (int i = 1; i <= qtdLinha; i++ ) {
  14.  
  15. linha = leitor.readLine();
  16. String[] dadosCSV = linha.split(VIRGULA);
  17. System.out.println(Arrays.toString(dadosCSV));
  18. System.out.println( dadosCSV[0]);
  19. System.out.println( dadosCSV[1]);
  20.  
  21. System.out.println( dadosCSV[2]);
  22. System.out.println( dadosCSV[3]);
  23. System.out.println( dadosCSV[4]);
  24. System.out.println(dadosCSV[5]);
  25. System.out.println("--------------------------");
  26.  
  27. if (pessoaJuridicaPublicaService.getPorId(Long.parseLong(dadosCSV[1])) == null) {
  28. indiciosComErros = indiciosComErros + 1;
  29. }
  30.  
  31.  
  32.  
  33. }
  34. leitor.close();
  35.  
  36. class ErroCSV {
  37. private int linhaErro;
  38. private String[] dados;
  39.  
  40. public ErroCSV(int linhaErro, String[] dados) {
  41. this.linhaErro = linhaErro;
  42. this.dados = dados;
  43. }
  44.  
  45. public int getLinhaErro() {
  46. return linhaErro;
  47. }
  48.  
  49. public String[] getDados() {
  50. return dados;
  51. }
  52. }
  53.  
  54. List<ErroCSV> erroCSVList = new Arraylist<>();
  55.  
  56. for (int i = 1; i <= qtdLinha; i++ ) {
  57.  
  58. linha = leitor.readLine();
  59. String[] dadosCSV = linha.split(VIRGULA);
  60. System.out.println(Arrays.toString(dadosCSV));
  61. System.out.println( dadosCSV[0]);
  62. System.out.println( dadosCSV[1]);
  63.  
  64. System.out.println( dadosCSV[2]);
  65. System.out.println( dadosCSV[3]);
  66. System.out.println( dadosCSV[4]);
  67. System.out.println(dadosCSV[5]);
  68. System.out.println("--------------------------");
  69.  
  70. if (pessoaJuridicaPublicaService.getPorId(Long.parseLong(dadosCSV[1])) == null) {
  71. erroCSVList.add(new ErroCSV(i, dadosCSV));
  72. }
  73.  
  74.  
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement