bonjour ,
j'ai des lignes a decouper des mots separés par |,
pour cela j'utilise StringTokenizer
j'ai plein de colonnes quand j'ouvre avec excel +26
le pb c'est qu'il ne m'affiche pas au dela de 15 avec StringTokenizer
voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 import java.io.FileReader; import java.io.BufferedReader; import java.io.IOException; import java.lang.*; import java.util.StringTokenizer; public class mytestcsv {// debut de class public static void main(String[] arguments) {//debut de main FileReader monFichier = null; BufferedReader tampon = null; try {//debut try catch 1 monFichier = new FileReader("d:\\mydoc.txt"); tampon = new BufferedReader(monFichier); int i=0; while (true) { // Lit ligne du fichier txt String ligne = tampon.readLine(); // Vérifie la fin de fichier if (ligne == null) break; //System.out.println(ligne); //decoupage de la ligne StringTokenizer st = new StringTokenizer(ligne, "|"); i++; String[] tab_str = new String[st.countTokens()]; for ( int j = 0; j<st.countTokens();j++ ) { tab_str[j] = st.nextToken(); } if (i>2){ System.out.println("------------------------------------"); System.out.println("ligne-> "+ligne); System.out.println("nb carac->"+ligne.length()); System.out.println("notice_id-> "+tab_str[0]); System.out.println("reception_id-> "+tab_str[1]); System.out.println("check_in-> "+tab_str[2]); System.out.println("heading-> "+tab_str[3]); System.out.println("proc-> "+tab_str[4]); System.out.println("doc_type-> "+tab_str[5]); System.out.println("preptype-> "+tab_str[6]); System.out.println("invoice-> "+tab_str[7]); System.out.println("dispatch-> "+tab_str[8]); System.out.println("reception-> "+tab_str[9]); System.out.println("applicdeadline-> "+tab_str[10]); System.out.println("exppublic-> "+tab_str[11]); System.out.println("nc-> "+tab_str[12]); System.out.println("publication-> "+tab_str[13]); System.out.println("receptype-> "+tab_str[14]); System.out.println("delfform-> "+tab_str[15]); System.out.println("FaxGateway-> "+tab_str[16]); System.out.println("------------------------------------"); } } // Fin du while } catch (IOException exception) {//try catch 1 exception.printStackTrace(); } finally { //try catch 1 try { tampon.close(); monFichier.close(); } catch(IOException exception1) { exception1.printStackTrace(); } }//fin try catch 1 } // Fin de main }//fin de class
et voici le resultat dans le viewer :
donc cette partie n'est pas pris en compte.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 ------------------------------------ ligne-> 2007/S 185-226238|07-188488-003|22/09/2007 03:01:24|4210NF|1|3|PT|17S|22/09/2007 00:00:00|22/09/2007 00:00:00|05/11/2007 00:00:00|27/09/2007 00:00:00|2|26/09/2007 00:00:00|EMAIL|XML|SJS_MPOS_XML-|2007-011668|CH001|FR|CH|CH|Vilen|CH-Ven: Appareils de mesure du rayonnement|Pl Scrrer Insut|/home/js/S-JS/data/input/email_newforms/XMLP_20070921230921_1_CH001-XML01-20070921.zip|6|22/09/2007 03:01:27|25/09/2007 11:05:22||25/09/2007 10:51:00|25/09/2007 10:51:03 nb carac->481 notice_id-> 2007/S 185-226238 reception_id-> 07-188488-003 check_in-> 22/09/2007 03:01:24 heading-> 4210NF proc-> 1 doc_type-> 3 preptype-> PT invoice-> 17S dispatch-> 22/09/2007 00:00:00 reception-> 22/09/2007 00:00:00 applicdeadline-> 05/11/2007 00:00:00 exppublic-> 27/09/2007 00:00:00 nc-> 2 publication-> 26/09/2007 00:00:00 receptype-> EMAIL delfform-> XML FaxGateway-> null ------------------------------------
alors est-ce qu'il y a une taille limite?
comment je peux faire pour qu'il prenne le reste de la ligne?
Merci pour votre aide
![]()
Partager