This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Groovy and the fly likes Duplicating eol characters in simple script? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Languages » Groovy
Bookmark "Duplicating eol characters in simple script?" Watch "Duplicating eol characters in simple script?" New topic
Author

Duplicating eol characters in simple script?

Bob Smitheeeee
Greenhorn

Joined: Jul 26, 2012
Posts: 5
Hi, I need some help with the following script. It inserts 2 newlines instead of 1 as I think it should:



Outputs:



This is a windows machine. Any ideas? Thanks!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302
    
    6

If you're going to use Groovy, then go all out man!



GenRocket - Experts at Building Test Data
Bob Smitheeeee
Greenhorn

Joined: Jul 26, 2012
Posts: 5
Gregg Bolinger wrote:If you're going to use Groovy, then go all out man!



Thanks Greg, did you try the code I post to observe the behavior? I'm looking for anyone who has an explanation, because it seems like a bug to me.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302
    
    6

You're adding a carriage return (\r) and a new line (\n). Of course you're going to get that output.
Bob Smitheeeee
Greenhorn

Joined: Jul 26, 2012
Posts: 5
Windows eol is \r\n. It happens with \n only as well. Without adding \r\n the output is:



Edit: corrected output.
 
Have you checked out Aspose?
 
subject: Duplicating eol characters in simple script?
 
It's not a secret anymore!