title: Simple java chat app reading image
body: <p>I tried to create a Chat application , but faced two problems, the first when sending the emoticon it is appear as follows
  <img src="https://i.stack.imgur.com/sGD0d.png" alt="enter image description here"></p>
  
  <p>And This is my code (sending emoticon)</p>
  
  <pre><code>private void sendEmotion(ImageIcon emoticon, URL url) {
  
      try {
          Image image = emotion.getImage();
          listModel.addElement(emoticon);
          jList2.setModel(listModel);
          BufferedImage img = ImageIO.read(new File(url.toURI()));
          ImageIO.write(img, "png", s.getOutputStream());
      } catch (Exception ex) {
          Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
      }
  }
  </code></pre>
  
  <p>reading text and emoticon</p>
  
  <pre><code> br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
          while (true) {
              // To read text
              String st = br.readLine();
              listModel.addElement(st);
             jList1.setModel(listModel);
              //to read imge
                BufferedImage image = ImageIO.read(socket.getInputStream());
  
                ImageIO.write(image, "png", new File("e:/image.png"));
                listModel.addElement(image);
                jList1.setModel(listModel);
  
          }
      } catch (IOException ex) {
          Logger.getLogger(MainServer.class.getName()).log(Level.SEVERE, null, ex);
      }
  </code></pre>
  
  <p>The second problem , when sending text and image from server to client, The client  can't read both (text or image not both)</p>