How to identify a new line in a files while parsing?
I am parsing a source file using the java parser and I need to get how many new lines the method has. the thing is that my implementation is returning zero, even though the method does have a new line. 

The following is my code:

    @Override
    	public void visit(MethodDeclaration m, Object arg) {
    		BlockStmt block = m.getBody();
    		List<Statement> stmts = block.getStmts();
    		this.nl = 0;
    		
    		Iterator<Statement> iter = stmts.iterator();
    		
    		while(iter.hasNext()){
    			
    			if(iter.next().toString().equals("\n")){
    				this.nl++;
    			}
    		}
    	}

Ive also trued comparing the length to 1, as '\n' is one character, but it failed as well.

Does anyone know how to be able to determine a new line please?
How to identify a new line in a files while parsing?
===

I am parsing a source file using the java parser and I need to get how many new lines the method has. the thing is that my implementation is returning zero, even though the method does have a new line. 

The following is my code:

    @Override
    	public void visit(MethodDeclaration m, Object arg) {
    		BlockStmt block = m.getBody();
    		List<Statement> stmts = block.getStmts();
    		this.nl = 0;
    		
    		Iterator<Statement> iter = stmts.iterator();
    		
    		while(iter.hasNext()){
    			
    			if(iter.next().toString().equals("\n")){
    				this.nl++;
    			}
    		}
    	}

Ive also trued comparing the length to 1, as '\n' is one character, but it failed as well.

Does anyone know how to be able to determine a new line please?