Bonjour les amis.
C'est la première fois que j'écris ici dans développez.net.
Bref, j'explique le problème :
J'ai une fichier texte qui contient des lignes comme ça :
Je veux faire une regroupement comme suit :
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 [#TasmanianDevil][#Marsupials] [#Koala][#isHardWorking] [#MaleStudentWith3Daughters][#Student][#hasChildren][#Female][#hasGender][#male][#hasChildren] [#Marsupials][#Animal] [#Forest][#Habitat] [#Parent][#Animal][#hasChildren] [#KoalaWithPhD][#Koala][#hasDegree][#PhD] [#Koala][#hasHabitat][#DryEucalyptForest] [#Animal][#hasGender] [#Quokka][#Marsupials] [#Student][#Person][#hasHabitat][#University][#isHardWorking] [#Parent][#Animal] [#Quokka][#isHardWorking] [#Female][#hasGender][#female] [#Person][#Animal] [#Rainforest][#Forest] [#GraduateStudent][#Student] [#Marsupials][#Person] [#Animal][#hasHabitat] [#DryEucalyptForest][#Forest] [#Male][#hasGender][#male] [#University][#Habitat] [#Koala][#Marsupials] [#GraduateStudent][#hasDegree][#BA][#BS]
[#C1][#P1][#P2]
[#C2][#P1][#P2]
[#C3][#P1][#P2]
[#C1][#P3][#P4]
[#C2][#P3][#P4]
[#C1][#P5][#P6]
Alors comme résultat finale :
[#C1][#P1][#P2][#P3][#P4][#P5][#P6]
[#C2][#P1][#P2][#P3][#P4]
[#C3][#P1][#P2]
Par exemple quand je fais un parcours sur les lignes je trouve [#Koala][#isHardWorking] et par la suite je trouve [#Koala][#hasHabitat][#DryEucalyptForest].
alors je regroupe les deux lignes et je les affecte dans un LinkedList comme ça [#Koala][#isHardWorking][#hasHabitat][#DryEucalyptForest].
Merci de m'aider à programmer ce problème en Java.
Partager