groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric MacAdie <>
Subject Help with socket programming and loops
Date Mon, 25 May 2015 15:48:18 GMT
Hello Groovy users.

I am trying to do some socket programming in Groovy. I am using code found
here as a template:

My problem is with the server code.

It reads in the input buffer from a reader using the reader.readLine()
method. It turns out it's a BufferedReader.

A problem that I am having is: What if the input is more than one line?

I have been trying for a few hours to get this.

Neither reader.getText(), reader.readLines() nor reader.eachLine() worked.

I tried a few things like this:
def reader = input.newReader()
            def cc = reader.eachLine {
                println "Here is the next element: ${it}"
            println "Done iterating"

            def reader = input.newReader()
            def iter = reader.iterator()
            while ( iter.hasNext() ) {
                println "Here is the next element: ${}"
                println "About to get next, do we have next? "
                println "iter is a ${iter?.getClass()?.getName()}"
            println "Done iterating"

           def holdLine
            while ( ( holdLine = reader.readLine() ) ) {
                println "holdLine: ${holdLine}"

            println "Done"

In each case, it reads each line, but it does not get to the line after the

Maybe there is something obvious that I am missing and I am making a
mistake only a noob would make, but why won't the code break out of the

= Eric MacAdie

View raw message