private synchronized String readLine(PipedInputStream in) throws IOException {
            String input = "";
            do {
                int available = in.available();
                if (available == 0) {
                    break;
                }
                byte b[] = new byte[available];
                in.read(b);
                input = input + new String(b, 0, b.length);
            } while (!input.endsWith("\n") && !input.endsWith("\r\n") && !input.endsWith("\r"));

            return input;
        }