title: HTML page won't load image when sent through socket java
body: <p>I have this simple HTML that loads how I want when I load it in Chrome. </p>
  
  <pre><code>&lt;body&gt;
      &lt;div&gt;&lt;h1&gt;Welcome to my webpage!&lt;/h1&gt;&lt;/div&gt;
      &lt;div&gt;This page is being hosted on the local machine.&lt;/div&gt;
      &lt;div&gt;Now, here's a picture of a cat. Please enjoy.&lt;/div&gt;
      &lt;img src="cat.jpg" alt="Business Cat" width="800" height="600"/&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>When I pass it through a socket in Java, I always get a broken image. I can't figure out why, because I'm just passing bytes through the socket. </p>
  
  <pre><code>File index = new File("index.html");
  
  byte[] bytes = new byte[16 * 1024];
  
  InputStream in = new FileInputStream(index);
  
  while (true)
  {
      int read = in.read(bytes);
      if (read &lt; 0)
           break;
      out.write(bytes, 0, read);
  }
  
  out.flush();
  out.close();
  </code></pre>
  
  <p>The image file "cat.jpg" is in the same directory as "index.html". What am I missing?</p>