title: Delphi to Java code conversion
body: <p>how can i convert the specific code written in Delphi to JAVA</p>
  
  <pre><code>  try
  
      LLine := TMemoryStream.Create;
      IdTCPClient1.IOHandler.WriteLn('atext');
  
      IdTCPClient1.IOHandler.ReadStream(LLine, -1);
  
      LLine.Position := 0;  
      LLine.Read(intval, 4); //the server is sending memstream as integer + ajpeg image
  
      Image1.Picture.Graphic.LoadFromStream(LLine);
  
  
    finally
     //free
    end;
  </code></pre>
  
  <p>the above code works perfectly with Delphi , but now i want to create a java client too , but  my own conversion is giving me error(java)</p>
  
  <pre><code> Image image = null ;
   Socket socket = new Socket(someIP, myport);
  </code></pre>
  
  <p>My conversion is </p>
  
  <pre><code>      InputStream in = socket.getInputStream();
        OutputStream out = socket.getOutputStream();
  
           String string = "atext\n";
  
           byte buffer[] = string.getBytes();
           out.write(buffer);
  
      in.skip(4); // i don't want the integer
  
     image = ImageIO.read(in);
  </code></pre>
  
  <p>the server is getting the text atext perfectly , but my java client is having a problem always image is showing a null value (i assigned a breakpoint and checked it );</p>