Home Segments Top Top Previous Next

624: Mainline

Given a FileOutputStream instance, you can write 1 byte at a time to that stream. You are more likely to want to be able to write characters and character strings to the stream, however, so you must declare a PrintWriter variable and create a PrintWriter instance from a FileOutputStream instance:

              *-- PrintWriter variable       
              |   
              v 
PrintWriter writer = new PrintWriter(stream); 
                                       ^ 
                                       | 
           FileOutputStream instance --*