Skip to content

Instantly share code, notes, and snippets.

@marcgeld
Created June 3, 2016 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcgeld/0691925e0138318afeea4141f02ee1e7 to your computer and use it in GitHub Desktop.
Save marcgeld/0691925e0138318afeea4141f02ee1e7 to your computer and use it in GitHub Desktop.
Generates a lot of text
#! /usr/bin/env groovy
import java.nio.file.attribute.BasicFileAttributes
TEXT_LEN = 9999 * 2
TEST_TEXT = "Alfa Beta"
def text = ""
def ratio = TEXT_LEN / TEST_TEXT.length()
//println ratio
if ( ratio < 1.0 )
{
text = TEST_TEXT.substring(0, TEXT_LEN)
}
else {
(ratio + 1).times{ idx ->
text += sprintf("%04d", idx ) + " ${TEST_TEXT} "
}
text = text.substring(0, TEXT_LEN)
}
println "Text Lenght: ${text.length()}"
File file = new File("test.txt")
file.write text
println "Absolute path: ${file.getAbsolutePath()}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment