title: the proper way to listen for server sending attempt
body: <p>what is the proper way to determine that the server is sending data at the moment for example<br/>
  Pseudo-code<br/></p>
  
  <pre><code>while(true){
    //Do something
    if(ServerIsSendingrightnow){
      //Get The Data
      //Calling some method to handling the server's data
    }
    //Do something else
  }
  </code></pre>
  
  <p>does the method available() of InputStream class do the job ?<br/>
  Code:<br/></p>
  
  <pre><code> while(true){
     //Do something
     InputStream IStreamsock = Socket1.getInputStream();
     if(IStreamsock.available()){ //the server is sending data right now !
       //Get The Data
       //Calling some method to handling the server's data}
       //Do something else
  }
  </code></pre>
  
  <p>In C# we have MemoryStream class that serve as Dynamic byte array<br/>
  is there any java equivalent for MemoryStream<br/>
  can I do something like this in java:
  Pseudo-code<br/></p>
  
  <pre><code> while(DataIsAvailableInSocketInputStreamBuffer){
     MemoryStreamEquivalent.WriteByte(IStreamsock.ReadByte())}
  </code></pre>
  
  <p>I'm Sorry, but I'm new comer in java</p>