j'ai un petit souci avec mon bout de code.
Je récupère des données provenant d'un fichier txt.
Code qui pose problème:
c'est celui qui est en gras.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 private void parseDataLine(String line) { System.out.println("index :" + index ); for (int j=0; j<index ; j++){ System.out.println("j :" + j + " " + line.substring(indexTable[0][j], indexTable[1][j]).trim()); if (j==0) values = values + "'" + line.substring(indexTable[0][j], indexTable[1][j]).trim()+ "'" ; else values = values + "," + "'" + line.substring(indexTable[0][j], indexTable[1][j]).trim()+ "'" ; } values = values + ");"; }
données posant problème:
la ligne qui pose problème est en gras87300729022009873007290216/12/200916/12/2009SCI Mdouagon 000000000000160620 01 20080020307M48732008312410970 000
87300730562009873007305618/12/200918/12/2009CISSE Mamadou 0000000000000600007246317 03ECO20089913766D48732008312411050 000
87300731932009873007319322/12/200922/12/2009SCI Mdouagon 000000000000402600 01 20080020307M48732008312410970 000
87300733812009873007338129/12/200929/12/2009SCI Mdouagon 0000000000001750007648441 03SGB20080020307M48732008312410970 000
87500735232009875007352317/12/200917/12/2009MR ET MADAME SIDIBE VAKABA 0000000000000427507364481 03ECO20094105331T48752009320446639 000
87500735252009875007352517/12/200917/12/2009MR ET MADAME SIDIBE VAKABA 0000000000000427507364481 03ECO20094105331T48752009320446637 000
96900631732009969006317321/12/200921/12/2009BOSSON ATTIA 0000000000002457000081730 03BIA20098805280P49692009320446276 000
Tableau des index:
Affichage des données :column :reg_num_reg index1 :0 index2 :10
column :reg_num_pce index1 :10 index2 :24
column :reg_dat_rec index1 :24 index2 :34
column :reg_dat_val index1 :34 index2 :44
column :reg_part_vers index1 :44 index2 :94
column :reg_mont_reg index1 :94 index2 :112
column :reg_num_chq index1 :112 index2 :132
column :reg_cod_mod index1 :132 index2 :134
column :reg_cod_baq index1 :134 index2 :137
column :reg_annee_reg index1 :153 index2 :157
column :reg_cont_ncc index1 :141 index2 :149
column :reg_cod_imp index1 :149 index2 :150
column :reg_cod_pc index1 :150 index2 :153
column :reg_num_art index1 :153 index2 :169
column :reg_cod_com index1 :169 index2 :172
index :15
j :0 8730073056
j :1 20098730073056
j :2 18/12/2009
j :3 18/12/2009
j :4 CISSE Mamadou
j :5 000000000000060000
j :6 7246317
j :7 03
j :8 ECO
j :9 2008
j :10 9913766D
j :11 4
j :12 873
j :13 2008312411050
j :14 000
index :15
j :0 8730073193
j :1 20098730073193
j :2 22/12/2009
j :3 22/12/2009
j :4 SCI Mdouagon
j :5 000000000000402600
j :6
j :7 01
j :8
j :9 2008
j :10 0020307M
j :11 4
j :12 873
j :13 2008312410970
j :14 000
index :15
j :0 8730073381
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 10
j :1 20098730073381
at java.lang.String.substring(String.java:1934)
j :2 29/12/2009
at mis.ui.component.io.FilesScanner.parseDataLine(FilesScanner.java:135)
at mis.ui.component.io.FilesScanner.readDataFile(FilesScanner.java:70)
j :3 29/12/2009
j :4 SCI Mdouagon
at mis.ui.component.io.FilesScanner.<init>(FilesScanner.java:35)
at mis.ui.component.io.FilesScanner.main(FilesScanner.java:143)
j :5 000000000000175000
j :6 7648441
j :7 03
j :8 SGB
j :9 2008
j :10 0020307M
j :11 4
j :12 873
j :13 2008312410970
j :14 000
index :15
j :0 8750073523
j :1 20098750073523
j :2 17/12/2009
j :3 17/12/2009
j :4 MR ET MADAME SIDIBE VAKABA
j :5 000000000000042750
j :6 7364481
j :7 03
j :8 ECO
j :9 2009
j :10 4105331T
j :11 4
j :12 875
j :13 2009320446639
j :14 000
index :15
j :0 8750073525
j :1 20098750073525
j :2 17/12/2009
j :3 17/12/2009
j :4 MR ET MADAME SIDIBE VAKABA
j :5 000000000000042750
j :6 7364481
j :7 03
j :8 ECO
j :9 2009
j :10 4105331T
j :11 4
j :12 875
j :13 2009320446637
j :14 000
index :15
j :0 9690063173
j :1 20099690063173
j :2 21/12/2009
j :3 21/12/2009
j :4 BOSSON ATTIA
j :5 000000000000245700
j :6 0081730
j :7 03
j :8 BIA
j :9 2009
j :10 8805280P
j :11 4
j :12 969
j :13 2009320446276
j :14 000
index :15
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
Partager