Skip to content

Instantly share code, notes, and snippets.

@mamu7211
Created June 17, 2017 05:57
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 mamu7211/1cb9ecc54730b92a6e7ae7122cab14e5 to your computer and use it in GitHub Desktop.
Save mamu7211/1cb9ecc54730b92a6e7ae7122cab14e5 to your computer and use it in GitHub Desktop.
Create large file with random content.
def random = new Random()
def sizeInMB = 10
def size = 1024 * 1024 * sizeInMB
def chars = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'1','2','3','4','5','6','7','8','9','0',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'!','"','§','$','%','&','/','(',')','=','?','`',';',':','_','\'','*','"','~','\\','[',']','{','}','|'
,'<','>',';',':','-','\n']
def fileName = "C:\\temp\\payload-0.txt"
def file = new File(fileName)
if (file.exists()){
file.delete()
file.createNewFile()
}
new FileOutputStream(fileName).withWriter("UTF-8") { writer ->
println("STARTING")
while(file.length() < size) {
line=""
(0..1023).each{
line+=chars.get(random.nextInt(chars.size()))
}
writer << line
writer.flush()
print "\r\r\rSize: " + Math.round(file.length()/1024) + "kB"
}
}
println "\rFile size = " + Math.round(file.length()/1024) + "kB"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment