title: Java: Using BufferedReader and PrintWriter in Conjunction Causes Issues
body: <p>I'm trying to learn about Java's io package through experimentation and from the book "Java2: the Complete Reference (5th ed.)". Below, I have tried to make a very simple program to take some input using a BufferedReader instance and deliver some simple console output with PrintWriter instances.</p>
  
  <pre><code>package io;
  
  import java.io.*;
  
  public class UsingPrinterWriter {
      public static void main(String argv[]) {
          PrintWriter output = new PrintWriter(System.out, true);
          Profile hypro = Profile.promptedProfile();
          output.print(hypro);
          output.close();
          return;
      }
  }
  
  class Profile {
      private String first_name;
      private String last_name;
      private int age;
  
      Profile() {}
  
      Profile(String first_name, String last_name, int age) {
          this.first_name = first_name;
          this.last_name = last_name;
          this.age = age;
      }
  
      void setFirstName(String fn) {
          this.first_name = fn;
          return;
      }
  
      void setLastName(String ln) {
          this.last_name = ln;
          return;
      }
  
      void setAge(int a) {
          this.age = a;
          return;
      }
  
      static Profile promptedProfile() {
          Profile new_profile = new Profile();
  
          // create the writer and reader
          PrintWriter output = new PrintWriter(System.out, true);
          BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
  
          try {
              // prompt for first name
              output.print("Enter your first name: ");
              new_profile.setFirstName(input.readLine());
  
              // prompt for last name
              output.print("Enter your last name: ");
              new_profile.setLastName(input.readLine());
  
              // prompt for age
              output.print("Enter your age: ");
              while(true) {
                  try {
                      new_profile.setAge(Integer.parseInt(input.readLine()));
                      if(new_profile.age &gt; 0 &amp;&amp; new_profile.age &lt; 110) {
                          break;
                      }
                      throw new NumberFormatException("Out of bounds.");
                  } catch(NumberFormatException nfe) {
                      output.print("Invalid response, try again: ");
                  }
              }
              input.close();          
          } catch (IOException ioe) {
              output.println(ioe);
          } finally {
              output.close();
          }
  
          return new_profile;
      }
  
      @Override
      public String toString() {
          return String.format("Profile:\n  Name: %s %s\n  Age: %d\n", this.first_name, this.last_name, this.age);
      }
  }
  </code></pre>
  
  <p><strong>Issue 1</strong>:
  when I run this (Using the Eclipse IDE) the output I get is a blank terminal, where, once I enter a string, another string, and a valid integer, all one after the other in newlines, (then)the prompt lines where I do output.print(...) get printed. Here's an example to show what I mean:</p>
  
  <pre><code>first
  last
  20
  Enter your first name: Enter your last name: Enter your age:
  </code></pre>
  
  <p><strong>Issue 2</strong>:
  The line: <code>output.print(hypro);</code> won't get printed. Anything after the line <code>Profile hypro = Profile.promptedProfile();</code>.</p>
  
  <p>So I'd like to ask:</p>
  
  <ol>
  <li>what's going on here (the conceptual knowledge about these io classes that I seem to be missing) ?</li>
  <li>what can I do to resolve these issues?</li>
  </ol>
  
  <p>In advance, thank you.</p>
  
  <p>P.S. I'm already aware of the java.util.Scanner class but I want to solve this issue without using it. Also, I'm open to suggestions about any better programming practices that I should have implemented here.</p>