Skip to content

Instantly share code, notes, and snippets.

@bobbyjam99-zz
Created November 30, 2018 08:15
Show Gist options
  • Save bobbyjam99-zz/0f9eca3bda53a94599f434f49ce9b594 to your computer and use it in GitHub Desktop.
Save bobbyjam99-zz/0f9eca3bda53a94599f434f49ce9b594 to your computer and use it in GitHub Desktop.
import java.io.*
fun main(args: Array<String>) {
val inputFilePath = "/path/to/inputfile"
val outputFilePath = "/path/to/outputfile"
val times = 1
val lines = ArrayList<String>()
var header = ""
try {
val file = File(inputFilePath).absoluteFile
file.forEachLine {
if (it.isNotBlank()) {
lines.add(it)
}
}
header = lines.get(0)
lines.removeAt(0)
} catch (e: FileNotFoundException) {
println(e)
}
File(outputFilePath).bufferedWriter().use { out ->
out.appendln(header)
for(i in 1..times) {
for(s in lines) {
out.appendln(s)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment