Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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