For example if I assign multiple lines to a string as so:
while ((line = reader.readLine()) != null)
        {
            output += line + "\n";
        }
Is it possible for me to return output with line separators as one String?
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.
Server Program code (part of 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();
        }
    }
Client Program 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);
        }
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.
So if output for example equals:
One
Two
Three
Four
It returns as this:
One
Enter your choice:  (It prompts me for new command)
Two
Enter your choice:
Three
Enter your choice:
Four
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:
One
Two
Three
Four
Enter your choice:
 
     
    