title: Sending BufferedImages Over Sockets
body: <p>I want to send a buffered image across the network as part of my custom class.</p>
  
  <p>I currently just writeObject and readObject to get my class. </p>
  
  <p>To send the image im currently doing:</p>
  
  <p><code>((DataBufferByte) i.getData().getDataBuffer()).getData();</code></p>
  
  <p>How do i convert that back in to a BufferedImage? </p>
  
  <p>Is there a better way to be doing this?</p>
  
  <p>The class i send looks like:</p>
  
  <pre><code>public class imagePack{
  
  public byte[] imageBytes;
  public String clientName;
  public imagePack(String name, BufferedImage i){
      imageBytes = ((DataBufferByte) i.getData().getDataBuffer()).getData();
      clientName = name;
  }
  
      public BufferedImage getImage(){
       //Do something to return it}
  
  }
  </code></pre>
  
  <p>Thanks again</p>