Question

I need to change this method so that checkstyle will stop complaining at me.

The inner assignment error is in the for each loop. I want the same functionality but without the error. Thanks!

        for (String line; (line = br.readLine()) != null;) {
            //CODE
        }
Was it helpful?

Solution

Checkstyle doesn't like assignments inside other statements. You could change your for loop as follows:

for (String line = br.readLine(); line != null; line = br.readLine()) {
    // rest of your code
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top