my dog learned polymorphism*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 15286
    
    6

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



GenRocket - A Test Data Generation Platform
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: 15286
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Duplicating eol characters in simple script?
 
Similar Threads
Passing a file to a method
Read million rows from .csv
How to find end of file in java
File Reader
JRE causing defunct tail processes?