title: Java sockets: DataOutputStream or OutputStream?
body: <p>I'm still relatively new to sockets, and I haven't seen any information regarding this subject.</p>
  
  <p>To write to a connected socket, you can either use</p>
  
  <pre><code>socket.getOutputStream().write
  </code></pre>
  
  <p>Or create a new <code>DataOutputStream</code> from the socket <code>OutputStream</code> and write to that.</p>
  
  <ul>
  <li>What is considered "good practice", using a DataOutputStream or OutputStream?
  Most of <a href="http://pirate.shu.edu/~wachsmut/Teaching/CSAS2214/Virtual/Lectures/lecture18.html">the examples</a> I find on the internet use DataOutputStream (to send Strings, such as in a two way chat). </li>
  <li>Are there any advantages or disadvantages from using DataOutputStream over OutputStream?</li>
  <li>Is there any difference in performance that is noticeable between these two when, for example, sending files?</li>
  </ul>