Results 1 to 6 of 6

Thread: String in TXT problem

  1. #1
    DaoK
    Guest

    String in TXT problem

    I print a String with that method :
    Code:
        PrintWriter pw;
        pw = new PrintWriter(new FileOutputStream("FichierResultat.txt"));
        pw.println(sListeGagnant);
        pw.close();

    and i am supposed to got that :


    Code:
    *****     Résultats de la lotterie du Père Noël     *****
    
    Nombre de participants:			66
    Montant de la recette:			660.0
    Combinaison gagnante:			15105
    
    =====     Liste des gagnants     =====
    
    GOUDSOUZIAN ARI     	 3 sur 5 	35125
    CHRISTIN FRANCOIS     	 3 sur 5 	15136
    
    =====     Montant de lots     =====
    
    2 gagnant(s) 3 sur 5			16.5 chacun
    0 gagnant(s) 4 sur 5			0.0 chacun
    0 gagnant(s) 5 sur 5			0.0 chacun


    but when I go check in the .txt all newline is blackbox and in one line ??? Why ? Please help me it's for my final work and I have to send all for monday...that the only bug I have

  2. #2
    DaoK
    Guest
    if you need more information just post what you need, it's an important question please.

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    have you tried just using the print() method, and adding in the carriage returns yourself?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4
    DaoK
    Guest
    I used \n in the string to make the return, in the DOS windows all is ok but when I print it in a .txt it doesnt work well.

  5. #5

  6. #6
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    I get this too, but I haven't worried about it too much. I usually get this if I use Notepad. Try viewing in Wordpad instead--it usually resolves text file incompatibilities.

    Of that's not good enough and you take the previous advice of using print() and appending a \n to the end of your strings and find that that doesn't work either, try appending \r\n instead.

    cudabean

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width