title: why does ByteArrayInputStream doesn't return expected results?
body: <p>I am trying to interact with an application in windows server through telnet, so I am using TelnetClient() method. I could interact (send commands and retrieve results) using System.in.read(), however I want this program to run automatically without using any keyboard inputs. So, my question is, why does System.in.read() works, yet ByteArrayInputStream doesn't?</p>
  
  <p>This is my code so far :</p>
  
  <pre><code>public class telnetExample2 implements Runnable, TelnetNotificationHandler{
   static TelnetClient tc = null;
   public static void main (String args[]) throws IOException, InterruptedException{
    tc = new TelnetClient();
     while (true){
      try{
       tc.connect("192.168.1.13", 8999);
       }
       catch (SocketException ex){
        Logger.getLogger(telnetExample2.class.getName()).log(Level.SEVERE, null,ex);
       }
      Thread reader = new Thread(new telnetExample2());
      tc.registerNotifHandler(new telnetExample2());
      String command = "getversion"; //this is the command i would like to write
      OutputStream os = tc.getOutputStream();
      InputStream is = new ByteArrayInputStream(command.getBytes("UTF-8")); //i'm using UTF-8 charset encoding here
      byte[] buff = new byte[1024];
      int ret_read = 0;
      do{
       ret_read = is.read(buff);
       os.write(buff, 0, 10)
       os.flush();
      while(ret_read&gt;=0);
      }
   }
  
  public void run(){
   InputStream instr = tc.getInputStream();
   try{
    byte[] buff = new byte[1024];
    int ret_read = 0;
     do{
      ret_read = instr.read(buff);
      if(ret_read &gt;0){
       System.out.print(new String(nuff, 0, ret_read));
      }
     while(ret_read&gt;=0);}
    catch(Exception e){
    System.err.println("Exception while reading socket:" + e.getMessage());
    }
   }
  
  public void receiveNegotiation(int i, int ii){
   throw new UnsupportedOperationException("Not supported");
   }
  }
  </code></pre>