• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble writing to a file.  RSS feed

 
Charles Mulloy
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to get a program to scan web pages and it sort of works. As is reads the source it makes decisions based on what it finds, and writes to the disk. However it will only write so much then stop. My code is made to show what is being written as it being written. Though my program shows the file is being scanned all the way to the end, the file that is being written will stop at the spot every time. My code looks like this:


Anyone know why it's doing this?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget to close the input and output streams (by calling close() on them). Some streams have a buffer, and if you don't close or flush the stream properly, part of the data might not be written to the actual file.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!