title: Java send image from client to server
body: <p>Im coding a little program and i want the client to take a printscreen and then send the image to the server they are connected to.</p>
  
  <p>Heres the client code.</p>
  
  <pre><code>public void run() 
  {
      while(true)
      {
          Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
          BufferedImage PrintScreen = robot.createScreenCapture(screenRect);
          //what do I do here?!?!?!
          try {
              Thread.sleep(2000);
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>And here is the server code</p>
  
  <pre><code>public void run() 
  {
      while(true)
      {
          //Read image sent from client.
  
  
          //Sleep shit
          try 
          {
              Thread.sleep(2000);
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>Hopefully you can help me. I've tried to google to get my answer but there are some things i don't really understand. I've seen people converting the image to an array of bytes. Why do you have to do this?</p>