Salutations.

Je me construis un aide mémoire avec répertoire des erreurs que j'ai fait pour java en java qui était presque fini quand après quelques modification je me suis rendu compte que dans mon fichier texte je n'avais plus de retours a la ligne (??????????). Je ne me l'explique pas, si quelqu'un a une idée , sinon je modifirait mon code pour contourné le problème.

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
92
93
94
95
96
97
98
99
100
101
102
103
104
  private void jbt_nouveau_MouseClicked(java.awt.event.MouseEvent evt) {                                          
                                                // quand on clik sur la Jcbox
        try                                     // en cas d'érreur dans l'enregistrement
        {
            enrgistrement();                    // lancement de la procédur enregistrement
        }
        catch (java.io.IOException ioe)         //récupération des erreurs d'enregistrement'
        {
             proc_recherche.renvoi_erreur("io exeption dans frm_liste",ioe.getMessage());// renvoi dans la classe recherche a la procédur renvoi_erreurs qui affiche le message d'érreur
        }
    }
    
    private void enrgistrement ()throws java.io.IOException // Envoi a l'enregistrement et récupère donc les IOExeption'
    {
        String str_address = "";                         //string de récupération de l'addresse '
        String str_texte = "";                           //String de récupératios deu texte
        String str_liste = ""; 
        boolean bou_nouveau = false;                    //Indique si c'est un nouveau sujet ou pas'
        
        try
        {
            
            str_address = this.Jtxtf_nouveau.getText();  //récupération de l'addresse'
            if (str_address.equals(""))                  //compare a une string vide true si vrai
            {
                str_address = (String) this.Jcbox_liste.getSelectedItem();   //Si rien n'est inscrit dans le JTexte l'addresse est prise dans la JCBox'
            } 
            else
            {
                bou_nouveau = true;                     // indique que le JTexte est vide
            }
            
            str_texte = this.Jtxta_liste.getText();     //récupération d texte de la textaréa afin de le replacé dans un fichier
            
        }
        catch (java.lang.NullPointerException nlp) { proc_recherche.renvoi_erreur("java.lang.NullPointerException dans frm_liste",nlp.getMessage());}     // en cas d'érreur sur la string
        
     
        try
        {   
            proc_recherche.enregistrer(str_address,str_texte);  // Enregistrement du texte dans son fichier
            if (bou_nouveau)                                    // si c'est u n nouveau fichier'
            {
                int int_nombre_elements,int_compteur = 0;
                int_nombre_elements = vec_liste.size()-1;
                str_liste = "";
                while (int_compteur <= int_nombre_elements)
                {
                    str_liste = str_liste + (String)vec_liste.get(int_compteur++)+ "\n";
                }

                
                Jcbox_liste.addItem(str_address);               //ajout du titre du nouveau fichier dans la liste de la JComboBox
                proc_recherche.enregistrer("liste",str_liste);  //enregistrement de la liste dans le fichier liste
                Jtxtf_nouveau.setText("");                      // efacement du Jtexte
            }
        }
        catch(OptionalDataException e){proc_recherche.renvoi_erreur ( "OptionalDataException", e.getMessage()); }
        catch(StreamCorruptedException e){ proc_recherche.renvoi_erreur ( "StreamCorruptedException", e.getMessage()); }
        catch( WriteAbortedException e){ proc_recherche.renvoi_erreur ( "WriteAbortedException", e.getMessage()); }
        catch(CharConversionException e) {proc_recherche.renvoi_erreur ("CharConversionException", e.getMessage());}
        catch(EOFException e){ proc_recherche.renvoi_erreur ( "EOFException", e.getMessage());}
        catch(FileNotFoundException e){proc_recherche.renvoi_erreur ( "FileNotFoundException ", e.getMessage() +"Impossible de trouver le fichier"); }
        catch(IOError e){proc_recherche.renvoi_erreur ( "IOError", e.getMessage()); }
        catch(InterruptedIOException e){proc_recherche.renvoi_erreur ( "InterruptedIOException", e.getMessage()); }
        catch(InvalidClassException e){proc_recherche.renvoi_erreur ( "InvalidClassException", e.getMessage());}
        catch(InvalidObjectException e){proc_recherche.renvoi_erreur ( "InvalidObjectExceptionr", e.getMessage()); }
        catch(NotActiveException e){proc_recherche.renvoi_erreur ( "NotActiveException", e.getMessage());}
        catch(NotSerializableException e){proc_recherche.renvoi_erreur ( "NotSerializableException", e.getMessage());}
        catch(ObjectStreamException e){proc_recherche.renvoi_erreur ( "ObjectStreamException", e.getMessage());}
        catch(SyncFailedException e){proc_recherche.renvoi_erreur ( "SyncFailedException", e.getMessage());}
        catch(UTFDataFormatException e){proc_recherche.renvoi_erreur ( "UTFDataFormatException", e.getMessage());}
        catch(UnsupportedEncodingException e){proc_recherche.renvoi_erreur ("UnsupportedEncodingException", e.getMessage());}
        
    }                   

********************************************************
 public void enregistrer (String str_complement_adresse, String str_donnees)throws java.io.IOException
    {
        String str_addresse = "C:/Documents and Settings/Programation/Essais/Liste des erreurs/Liste/"+ str_complement_adresse +".txt";
        try
        {
            java.io.BufferedWriter  buw_ecrir =  new java.io.BufferedWriter(new java.io.FileWriter(str_addresse));
            buw_ecrir.write(str_donnees);
            
             buw_ecrir.close();
           :aie: 
        }
        catch(CharConversionException e){renvoi_erreur ("CharConversionException", e.getMessage());}
        catch(EOFException e){renvoi_erreur ( "EOFException", e.getMessage());}
        catch(FileNotFoundException e){renvoi_erreur ( "FileNotFoundException 2", e.getMessage() +"Impossible de trouver le fichier");}
        catch(IOError e){ renvoi_erreur ( "IOError", e.getMessage()); }
        catch(InterruptedIOException e){renvoi_erreur ( "InterruptedIOException", e.getMessage());}
        catch(InvalidClassException e){ renvoi_erreur ( "InvalidClassException", e.getMessage());}
        catch(InvalidObjectException e){renvoi_erreur ( "InvalidObjectExceptionr", e.getMessage());}
        catch(NotActiveException e){renvoi_erreur ( "NotActiveException", e.getMessage());}
        catch(NotSerializableException e){renvoi_erreur ( "NotSerializableException", e.getMessage());}
        catch(ObjectStreamException e){renvoi_erreur ( "ObjectStreamException", e.getMessage());}
        catch(SyncFailedException e){renvoi_erreur ( "SyncFailedException", e.getMessage());}
        catch(UTFDataFormatException e){renvoi_erreur ( "UTFDataFormatException", e.getMessage());}
        catch(UnsupportedEncodingException e) {renvoi_erreur ("UnsupportedEncodingException", e.getMessage());}
        catch(IOException e){ renvoi_erreur ( "IOException", "Impossible de lir le fichier");}
    }
Le code est fait sous NetBean 5.5, j'ai bien les \n dans la string qui est envoyé dans le fichier texte, mais je ne retrouve qu'une ligne ou tout est collé.



Merci d'avance, a tout ceux qui vont se creusé la tête.

Janosor