Bom dia meu nome é Rafael e gostaria de saber se poderiam me ajudar, estou tentando ler um arquivo txt no netbeans e enviar as informações para o banco de dados SQL Server 2014, mas estou tendo problemas.
Segue informações do txt.
|C100|0|1|04400552000148|55|00|2|176676|13131104400552000148550020001766761001766766|07112013|03012014|42250|1|0||42250|0|0|0|0|0|0|0|0|0|274,63|1267,5|||
|C100|0|1|04400552000148|55|00|2|176677|13131104400552000148550020001766771001766771|07112013|03012014|42250|1|0||42250|0|0|0|0|0|0|0|0|0|274,63|1267,5|||
Meu código está conseguindo filtrar as informações, mas na hora de passar para o banco os 2 últimos valores nulos está dando problemas.
Segue codificação:
public void Inserir() throws SQLException {
File dir = new File(“C:\Users\rafael.drumond\Desktop\BDO Java projeto”);
    File arq = new File(dir, "teste.txt");
    try {
        Statement stmt = con.createStatement();
        //Indicars o arquivo que será lido
        FileReader fileReader = new FileReader(arq);
        //Criar o objeto bufferReader que nos
        // oferece o método de leitura readLine()
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        //String que irá receber cada linha do arquivo
        String linha = "";
        //Fazer um loop linha a linha no arquivo,
        // enquanto ele seja diferente de null.
        //O método readLine() devolve a linha na
        // posicao do loop para a variavel linha.
        while ((linha = bufferedReader.readLine()) != null) {
            //imprimimosr a linha
            //System.out.println(linha);
            String[] str = linha.split("\\|");//Aqui
            for (int i = 1; i < str.length; i++) {
                if (str[1].equals("C100")) {
                    System.out.println("str[" + i + "] :" + str[i]);
                }
            }
            if (str[1].equals("C100")) {
                // Prepare a statement to insert a record  
                String sql = "insert into C100 (REG, IND_OPER, IND_EMIT, COD_PART, COD_MOD, COD_SIT, SER, NUM_DOC, CHV_NFE, DT_DOC,"
                        + " DT_E_S, VL_DOC, IND_PGTO, VL_DESC, VL_ABAT_NT, VL_MERC, IND_FRT, VL_FRT, VL_SEG, VL_OUT_DA,"
                        + " VL_BC_ICMS, VL_ICMS, VL_BC_ICMS_ST, VL_ICMS_ST, VL_IPI, VL_PIS, VL_COFINS, VL_PIS_ST,VL_COFINS_ST) values ('"
                        + str[1] + "','" + str[2] + "','" + str[3] + "','" + str[4] + "','" + str[5] + "','" + str[6] + "','" + str[7] + "','"
                        + str[8] + "','" + str[9] + "','" + str[10] + "','" + str[11] + "','" + str[12] + "','" + str[13] + "','" + str[14] + "','" + str[15] + "','" + str[16]
                        + "','" + str[17] + "','" + str[18] + "','" + str[19] + "','" + str[20] + "','" + str[21] + "','" + str[22] + "','" + str[23]
                        + "','" + str[24] + "','" + str[25] + "','" + str[26] + "','" + str[27] + "','" + str[28] + "','" + str[29] + "');";
                //Execute the insert statement  
                stmt.executeUpdate(sql);
            }
        }
        //liberar o fluxo dos objetos ou fechar o arquivo
        fileReader.close();
        bufferedReader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Poderiam me ajudar?
Desde já muito obrigado.
