File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Where did the contents of my .txt. file go? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Where did the contents of my .txt. file go?" Watch "Where did the contents of my .txt. file go?" New topic
Author

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

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
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

Joined: May 10, 2001
Posts: 3244
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.


Dave
Abitman Liu
Greenhorn

Joined: Apr 13, 2002
Posts: 12
where is your code?


i am abitman !
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Oops!
Sorry about that! (Is it still Monday??)

[ April 17, 2002: Message edited by: Jennifer Sohl ]
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
You might want to add
bw.flush();
bw.close();
at the end of your program and everything should be alright


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Aha. Thank you very much. Worked like a charm!
 
jQuery in Action, 2nd edition
 
subject: Where did the contents of my .txt. file go?
 
Similar Threads
JFileChooser showing files and directory
To Convert a .txt file into .html file
Copy file
renameTo()
Doubt in Renaming File