Printing multiple lines returned by BufferedReader
<p>I'm writing a program that basically sends linux command through java and then prints back the output.  It works fine if the output is one line only but for multiple lines output I can't figure out what I'm doing wrong.  For example to check the memory usage I use the "free" command but it only returns lines 1 and 3.  Here is my code:</p>

<pre><code>if (clinetChoice.equals("3"))
    {
        String command = "free";

        Process process = Runtime.getRuntime().exec(command);

        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

        System.out.println("You Chose Option Three");

        String line;            

        while ((line = reader.readLine()) != null)
        {
            output += line;
            System.out.println(line);
            line = reader.readLine();
        }

    }
</code></pre>

<p>When I run this it only returns:</p>

<pre><code>total  used  free  share  buffers  cached
-/+ buffers/cache:  6546546  65464645
</code></pre>

<p>Client Code:</p>

<pre><code>while ((fromServer = input.readLine()) != null)
    {
        System.out.println("Server: " + fromServer);            
        if (fromServer.equals("Bye"))
            break;          

        System.out.print("Enter your choice: ");
        fromClient = stdIn.readLine().trim();

        if(fromClient.equals("1"))
        {
            System.out.println("Client: " + fromClient);
            output.println(fromClient);

        }
        if(fromClient.equals("2"))
        {
            System.out.println("Client: " + fromClient);
            output.println(fromClient);

        }
        if(fromClient.equals("3"))
        {
            System.out.println("Client: " + fromClient);
            output.println(fromClient);

        }
        if(fromClient.equals("4"))
        {
            System.out.println("Client: " + fromClient);
            output.println(fromClient);
            break;

        }


    }
</code></pre>
