Can single String contain multiple lines?
<p>For example if I assign multiple lines to a string as so:</p>

<pre><code>while ((line = reader.readLine()) != null)
        {
            output += line + "\n";
        }
</code></pre>

<p>Is it possible for me to return output with line separators as one String?</p>

<p>I'm writing a Socket program that has Client and Server program, where Client sends request to Server and server returns that request in form of a String back to Client, but some String are multiple lines.</p>

<p>Server Program code (part of 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>Client Program code:</p>

<pre><code>while ((fromServer = input.readLine())+"\n" != 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);

        }
</code></pre>

<p>fromServer in Client program is output from Server program.  This works fine for output that's one line, but if its multiple lines I can't figure out how to print it all at once.</p>

<p>So if output for example equals:  </p>

<pre><code>One
Two
Three
Four
</code></pre>

<p>It returns as this:</p>

<pre><code>One
Enter your choice:  (It prompts me for new command)
Two
Enter your choice:
Three
Enter your choice:
Four
</code></pre>

<p>So it basically prints one line, ask me for new choice and doesn't matter what I enter it prints second line, then third line and so forth until it reaches last line, instead of printing like this:</p>

<pre><code>One
Two
Three
Four
Enter your choice:
</code></pre>
