title: Java Input and Output
body: <p>Explain the difference between the outputs of the following two fragments of code for outputting an int i to a file:</p>
  
  <p>i)</p>
  
  <pre><code>PrintWriter outfile = new PrintWriter(new FileWriter("ints.txt"));
  outfile.print(i);
  </code></pre>
  
  <p>ii)</p>
  
  <pre><code>DataOutputStream out = new DataOutputStream(new FileOutputStream("ints.dat"));
  out.writeInt(i);
  </code></pre>
  
  <p>I think the Printer writer takes a string and tranforms it into a stream of unicode characters, whereas  dataoutput stream converts the data items to sequence of bytes.</p>
  
  <p>What more would you add?</p>