Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where did the contents of my .txt. file go?

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. The following is some code I got off of sun's website that shuffles the contents of whatever file you tell it to. I modified the code so instead of going to std out, it puts the contents back into the file I read it from. My problem is, I had a .txt file with a little over 3000 lines in it. After I ran the program through, I only had 1365 lines. I tried running a different .txt file through that only had 1077 lines in it, and after running the program, I was left with 0 lines in the .txt file.
Did I forget to do something in my code? Why aren't all of my lines coming back?
Thanks for any help in advance!
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jennifer Sohl:
Hi. The following is some code I got off of sun's website...

umm, Jennifer, you didn't post the code.
 
Abitman Liu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where is your code?
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops!
Sorry about that! (Is it still Monday??)

[ April 17, 2002: Message edited by: Jennifer Sohl ]
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to add
bw.flush();
bw.close();
at the end of your program and everything should be alright
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha. Thank you very much. Worked like a charm!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic